Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
currently I have created a straight table with data and the coloumns I have are of the current date selected , and also of 3 previous days
meaning
selected day =date(kpi_date),
selected day - 1 =date(kpi_date-1),
selected day -2 =date(kpi_date-2),
selected day -3 =date(kpi_date-3)
Value wise I'm trying to filter the data as follows
I have this modifier Sum({$<KPI={"NEW REGISTRATIONS"},kpi_date={"$(=GetFieldSelections(kpi_date))"}>}registration_count) which works
BUT for the day -1, day -2, day -3 I can't get it to work by doing Sum({$<KPI={"NEW REGISTRATIONS"},kpi_date={"$(=GetFieldSelections(kpi_date) -1 )"}>}registration_count)
How can I get this working please, any suggestions are appriciated.
Thanks
Steve
You've selected a specific kpi_date, right? Even your working expression could be simplified.
sum({<KPI={'NEW REGISTRATIONS'}>} registration_count)
The only thing that really matters is that I removed the kpi_date check. You already have it selected, so there's no need to use set analysis to pick what you selected. On top of that I removed the $ because it isn't necessary, and I put "NEW REGISTRATIONS" in single quotes. Single quotes for literals, double quotes for search strings. Now if you search for "NEW REGISTRATIONS" it will find 'NEW REGISTRATIONS', so they are functionally equivalent, and any performance difference is probably measured in picoseconds or something, but there's still no reason to search.
You have a couple problems with the second expression. First, no reason to getfieldselections. You can just refer to kpi_date directly. In fact, I THINK the getfieldselections might return the text version of the date, in which case you'd fail to subtract 1, return null, and not find it. But if you just use kpi_date, you kind of have the opposite problem. Not it takes it as a number and subtracts 1 from it. That would be fine except for a QlikView shortcoming - QlikView compares the text equivalent of your date to the text equivalent of your expression. So it would end up comparing text like '05/06/11' to 40651 or whatever, and find that they don't match. So when using dates in set analysis, you have to make sure they remain formatted as dates, and in the same format as the field you're comparing them to. I suspect this would do the trick:
sum({<KPI={'NEW REGISTRATIONS'},kpi_date={'$(=date(kpi_date - 1))'}>} registration_count)
If not, perhaps kpi_date isn't in your default date format, and you'll need to add a formatting string to the date() function in there. Or maybe I have a syntax or other error.
You've selected a specific kpi_date, right? Even your working expression could be simplified.
sum({<KPI={'NEW REGISTRATIONS'}>} registration_count)
The only thing that really matters is that I removed the kpi_date check. You already have it selected, so there's no need to use set analysis to pick what you selected. On top of that I removed the $ because it isn't necessary, and I put "NEW REGISTRATIONS" in single quotes. Single quotes for literals, double quotes for search strings. Now if you search for "NEW REGISTRATIONS" it will find 'NEW REGISTRATIONS', so they are functionally equivalent, and any performance difference is probably measured in picoseconds or something, but there's still no reason to search.
You have a couple problems with the second expression. First, no reason to getfieldselections. You can just refer to kpi_date directly. In fact, I THINK the getfieldselections might return the text version of the date, in which case you'd fail to subtract 1, return null, and not find it. But if you just use kpi_date, you kind of have the opposite problem. Not it takes it as a number and subtracts 1 from it. That would be fine except for a QlikView shortcoming - QlikView compares the text equivalent of your date to the text equivalent of your expression. So it would end up comparing text like '05/06/11' to 40651 or whatever, and find that they don't match. So when using dates in set analysis, you have to make sure they remain formatted as dates, and in the same format as the field you're comparing them to. I suspect this would do the trick:
sum({<KPI={'NEW REGISTRATIONS'},kpi_date={'$(=date(kpi_date - 1))'}>} registration_count)
If not, perhaps kpi_date isn't in your default date format, and you'll need to add a formatting string to the date() function in there. Or maybe I have a syntax or other error.
John, you are great, have updated the expression as you suggested and it works, I will be validating the counts later with the data warehouse HOWEVER, at least when selecting a date, I actually see different values for the different days.
one of my problems was not understanding exactly the format of the expression and the use of modifiers, cos I realised that I was on the right track but still not enough 🙂
Thanks a million!
Steve
Hi John,
Just to let you know, I checked the values with the data warehouse and they work fine,
I have noticed something but, maybe you or someone can explain the logic based on the screen shot I have attached.
If I selected the actual created_date (our kpi_date) the values will change as expected and as seen in the screen shot. having said so, I have created a master_calendar which is linked to that created_date and although if I select the correct date, like lets say 29/03/2011, the other values of 28,27,26 will come to 0.
Why is that? isn't created_date ={'$(=date(created_date - 1)), based on the current value rather than the actual selected field value. not sure if I make sense but how does qlikview interpret this.
Again thanks for your help before, it was valuable
Steve
Managed to sort this out, not sure what the prob was but having two calendars with different type of days confused the file, so now its sorted.