Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
zjalalacssi
Partner - Contributor III
Partner - Contributor III

Display the 2 KPI for the Current Date and the Comparable Date

Hi Everyone,

I have an issue displaying Two Kpis with different Dates on the same Row.

I have a calendar with these values:

Calendar.PNG

This calendar is linked to my fact table using the Date field

i need to display a table with the following informations:

DateKpisKpis Comparable Date
2018-01-064010  (2017-01-07)

 

Using Set Analysis i have 2 rows Displayed like this:

DateKpisKpis Comparable Date
2018-01-06400
2017-01-07010

 

Can you help me figure it out please?

Thank you

Labels (1)
1 Solution

Accepted Solutions
miskinmaz
Creator III
Creator III

this is not possible with the set analysis and the workaround will be through script.

Please find the attached file for the same. You need to join the comparable date again with the date and calculate the total sum where max date will be equal to date.

 

View solution in original post

10 Replies
miskinmaz
Creator III
Creator III

what is the expression you have used in second expression 

Kpis Comparable Date
zjalalacssi
Partner - Contributor III
Partner - Contributor III
Author

The First one: sum({<[Date]={"$(v_MaxDate)"}>} KPI)

The second one: sum({<[Date]={"$(v_MaxDateComp)"}>} KPI)

My Variables :

v_MaxDate=max(Date)

v_MaxDateComp=max(day_id_day_comp)

Thank you

 

miskinmaz
Creator III
Creator III

Try to use two expression:

1 KPI: sum({<Date={"$(=max(Date))"}>}KPI)

2 KPI for prev day kpi: sum({<Date={"$(=max(Date)-1)"}><date={"$(=max(date))"}>}KPI)</date={"$(=max(date))"}>

 

zjalalacssi
Partner - Contributor III
Partner - Contributor III
Author

Thank you,

It's not the previous Day, it's a comparable day of last year.

Example: for: 06/07/2019 the comparable day is: 07/07/2018

miskinmaz
Creator III
Creator III

ok so try 

sum({<Date={"$(=date(addmonths(max(Date)-1,-12),'MM/DD/YYYY'))"}>}KPI)

zjalalacssi
Partner - Contributor III
Partner - Contributor III
Author

The hard part is that the Comparable day is already calculated by the company it's not a standard calculation rule, but it's calculated based on some other rules defined by the company.

for each date there is a comparable day , i can't apply addmonths(max(Date)-1,-12) for 2019-08-06 because the comparable day won't be equal to 2018-08-07

com.PNG

 

miskinmaz
Creator III
Creator III

can you post the sample app. There are many factors that your expression is not working as expected

zjalalacssi
Partner - Contributor III
Partner - Contributor III
Author

Yes, here is a sample app of my data

the result i'm trying to have is: 

DateSum(Nbcust)Sum(Nbcust) Comparable Date
2019-08-061415
2019-08-051034
2019-08-046544
2019-08-038721
2019-08-0246 
2019-08-0118 
2018-08-0715 
2018-08-0634 
2018-08-0544 
2018-08-0428 
2018-08-0321 
miskinmaz
Creator III
Creator III

this is not possible with the set analysis and the workaround will be through script.

Please find the attached file for the same. You need to join the comparable date again with the date and calculate the total sum where max date will be equal to date.