Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
DanielLief
Contributor
Contributor

If statement in line chart

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

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

 

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

0 Replies