Skip to main content
Announcements
Join us on Sept. 17 to hear how our new GenAI Assistant empowers data professionals: REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
hadari
Contributor III
Contributor III

KPI doesn't calculate correctly the last year when I choose quarter-year

 

I created variable vLastyear with this expression: =year(max(Date))-1.
I created a KPI :

sum( {<Year={'$(vLastYear)'}>} margin) and it gives me 0 as an output of the margin when I select Q1-2019 even though it recognized it in the ok statement as sum( {<Year={'2018'}>} margin) when I have data for the year 2018.. why it gives me 0 as an output in qlik sense when the selected period is Q1-2019

hadari_0-1715673921840.pnghadari_1-1715673980439.png

 

Labels (2)
8 Replies
mpc
Partner - Specialist
Partner - Specialist

Hi, 

To be sure, can you share your Data Model please ? 

kind regards

From Next Decision with love
Helpful, like it, solved, mark it
hadari
Contributor III
Contributor III
Author

 
hadari
Contributor III
Contributor III
Author

The KPI is on the dashboard:

hadari_0-1715677447718.png

you can see there is 0 when I select the Q1-2019 quarter from the graph 

mpc
Partner - Specialist
Partner - Specialist

Thanks:

Maybe this one: sum({<Year={'$(vLastYear)'},YearQuarter=>}margin)

From Next Decision with love
Helpful, like it, solved, mark it
hadari
Contributor III
Contributor III
Author

and if I want it to calculate the Q1-2018 if I choose Q1-2019?
when I use this expression it calculate all 2018 when I select "q1-2019" for the second KPI and the for the first KPI it calculate just for the Q1-2019.
this is my first KPI: =sum( {$<Year={'$(vMaxYear)'}>} margin)

mpc
Partner - Specialist
Partner - Specialist

Then can you try this one: sum({<"Num(YearQuarter)"={"$(=Num(AddYears(YearQuarter,-1)))"}>}margin) 

From Next Decision with love
Helpful, like it, solved, mark it
hadari
Contributor III
Contributor III
Author

It gives the same output as the first KPI- meaning the margin of the same  selected YearQuarter.
It doesn't recognize as a year- see the pic attached.

In addition- I want to write an expression that will calculate the margin of the last year if I choose year and the margin of the same quarter for the last year if I choose YearQuarter ( and so on if I choose Yearmonth) for the same expression ...

 

hadari_0-1715681063079.png

 

 

mpc
Partner - Specialist
Partner - Specialist

Hi, 

This one: Sum({<YearQuarter={'$(=Year(YearQuarter)-1 & '-Q' & ceil(month(YearQuarter)/3))'}, Year={'$(=Year(Year-1))'} >}margin)

Please see "New sheet" sheet for details 

From Next Decision with love
Helpful, like it, solved, mark it