Hello guys,
I'm developing a simple application and want to show revenue in a line chart (over month). I am showing two line, selected year in blue and previous year in purple.
If the user selects this year (2021), the chart is showing 2021 vs. 2020. Since this year is not over yet, I want to show YTD numbers for 2021 and 2020.
![DanielLief_0-1626441531153.png DanielLief_0-1626441531153.png](https://community.qlik.com/t5/image/serverpage/image-id/58742iA14650779B9187A5/image-size/medium?v=v2&px=400)
vCY = 2021
vMaxMonthCY = 7
if(Year=$(=vCY),
count({$<Kreis={"1*"},[Year]={"$(=max(year(Datum)-1))"},Month={"<=$(vMaxMonthCY)"}>} distinct %veakopID),
count({$<Kreis={"1*"},[Year]={"$(=max(year(Datum)-1))"}>} distinct %veakopID))
Somehow the if statement is not working correctly. If I just write:
count({$<Kreis={"1*"},[Year]={"$(=max(year(Datum)-1))"},Month={"<=$(vMaxMonthCY)"}>} distinct %veakopID)
![DanielLief_0-1626442370673.png DanielLief_0-1626442370673.png](https://community.qlik.com/t5/image/serverpage/image-id/58745i5FC332D56D16014C/image-size/medium?v=v2&px=400)
The chart is showing what I expect. Included in the if statement it always uses the else path.
if(Year=$(=vCY),
1,
0)
Using this as a test, it shows 1. So the if clause is working.
I have no idea what to change. Maybe one of you have an idea?
Cheers
Daniel