Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

create flag to use for comparison with expression counts of reported incidents

Hi everyone.

I am trying to create a chart where I can compare number of incidents reported this year (up to todays date, day number) vs previous years (also accordingly up to same day number from 2007 and upwards).

Example:

Todays day number of year is 222, then compare;

2007 - up to day 222 incidents reported

2008 - up to day 222 incidents reported

.......

2016 - up to day 222 incidents reported.

In my script I have the following:

    LOAD
     
TempDate AS %IncidentReportedKey,
     
TempDate AS  [Incident ReportedDate],
     
Week(TempDate) AS ReportedWeek,
     
Year(TempDate) AS ReportedYear,
     
Month(TempDate) AS ReportedMonth,
     
Day(TempDate) AS ReportedDay,

I then go on to create a flag, to check whether if day number of year is less than todays date.

        if(Day(TempDate) <= Day(today()), 1, 0) as IncidentReportedDate_Flag.

I then use this flag in an Expression in a chart, like this, with a variable vUpToToday = 1;

    = if(vUpToToday = 1, =count({$<ReportedYear={">2007"}>},IncidentReportedDate_Flag={1}>}DISTINCT(Incidents))

      ,

        =count({$<ReportedYear={">2007"}>}DISTINCT(Incidents)) )

I have created a button that when hit acitvates the variable vUpToToday = 1, and then shows the respected comparisons, else just shows reported incidents from year to year.

I think my problem is with the written flag, how can I manage to create a flag that focuses on days in year?

1 Solution

Accepted Solutions
sunny_talwar

Got it Makes much more sense now....

Try this

If(SetDateYear(TempDate, Year(Today()) <= Today(), 1, 0) as IncidentReportedDate_Flag

View solution in original post

6 Replies
sunny_talwar

So basically show all days (for all months and all years) up until today when Variable vUpToToday = 1?

Not applicable
Author

Yes, basically. And in the Expression then Count the number of incidents reported.

If this is the "all incidents report" from year to year:

Skjermbilde.PNG

Then by pressing a button "Up to this point in year" I want the 2016 to show total incidents reported up to date (day number 222 for example), and the remaining columns over the years also show total incidents reported up to day number 222 for that year respectively.

sunny_talwar

Got it Makes much more sense now....

Try this

If(SetDateYear(TempDate, Year(Today()) <= Today(), 1, 0) as IncidentReportedDate_Flag

Not applicable
Author

Thanks for the input Sunny.

I tried your suggestion, and for testing I have extracted two listboxes where one shows days, and the other weeks, like

this:

(on the left: reportedDayNumber, on the right: reportedWeekNumber)

Skjermbilde.PNG

Today is the 15 August of 2016, whick corresponds to week number 32. So I marked the daynumbers from 1 to 15, then the right column should have been marked from weeknumber 1 up to week number 32, if this was to work.

So if today is 15 August of 2015, which corresponds to day 227 of 365 of the year, this should be linked to the day number of the month, which again is linked to week number.

sunny_talwar

I am not sure what you are trying to do here. I know you have provided examples above, but I am having a hard time interpreting. We can do 2 things here, either someone else might give it a try to help you out, or you can try providing another example, may be a sample with the expected output.

Best,

Sunny

Not applicable
Author

Hi again Sunny, I modified your suggestion above slightly, and it seems to work perfectly for me now. Just what I was looking for, I just didnt see it myself.

Thank you!!