Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
alexpanjhc
Specialist
Specialist

Bar chart not showing what i expected

I have a simple chart with dimension Year

and two measures

1:

if(Year=$(v_CY),
sum({<Year={$(v_CY)},  [Quarter Name] = , [Month] = , Date = {"<=$(=Max([Date]))"} >}  Volume *[Rate] *Factor) ,
Sum({<Year= ,[Quarter Name] = , [Month] = , Date = {"<=$(=Max([Date]))"} >}  Volume*[Rate]))

2:

if( Year=$(v_CY),
Sum({<Year={$(v_CY)} ,[Quarter Name] = , [Month] = , Date = {"<=$(=Max([Date]))"} >}  Volume*[Rate]),
if( Year  =$(v_PY1),
Sum({<Year={$(v_PY1)} ,  [Quarter Name] = , [Month] = , Date = {"<=$(=addyears(Max([Date]), -1))"} >} Volume*[Rate]),
if( Year  =$(v_PY2),
Sum({<Year={$(v_PY2)} , [Quarter Name] = , [Month] = , Date = {"<=$(=addyears(Max([Date]), -2))"} >} Volume*[Rate]),

)))

 

so i assume for the three years of data i'd have 6 bars, but i only have current year two bars and previous year 1 bar each.

If i select all three years , 6 bars would all show. But i cant do it as only one year can be selected.

How to show all bars? 

thank you!

Labels (2)
5 Replies
anat
Master
Master

If always evaluate one condition, u can create multiple expression and apply conditional show based on the selection of year

vinieme12
Champion III
Champion III

Try below

MEasure1

if(Year=$(v_CY)
,sum({<Year={">$(=$(v_CY)-2)<=$(v_CY)"},[Quarter Name] = , [Month] =  >}  Volume *[Rate] *Factor) 
,Sum({<Year={">$(=$(v_CY)-2)<=$(v_CY)"},[Quarter Name] = , [Month] = >}  Volume*[Rate])

)

 

MEasure2

Sum({<Year={">$(=$(v_CY)-2)<=$(v_CY)",[Quarter Name] = , [Month] = , Date = {"<=$(=Max([Date]))"} >}  Volume*[Rate])

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
alexpanjhc
Specialist
Specialist
Author

thank you! its a charm.

alexpanjhc
Specialist
Specialist
Author

Sorry i realized that the year 2023 has to be selected, even i used year= in the set analysis, the bars for the 2nd measure still not showing...

vinieme12
Champion III
Champion III

what is the variable definition for  $(v_CY) ?

 

MEasure1

if(Year=$(=Max(Yearfield))
,sum({<Year={">$(=Max(Yearfield)-2)<=$(=Max(Yearfield))"},[Quarter Name] = , [Month] =  >}  Volume *[Rate] *Factor) 
,Sum({<Year={">$(=Max(Yearfield)-2)<=$(=Max(Yearfield))"},[Quarter Name] = , [Month] = >}  Volume*[Rate])

)

 

MEasure2

Sum({<Year={">$(=Max(Yearfield)-2)<=$(=Max(Yearfield))"},[Quarter Name] = , [Month] = , Date = {"<=$(=Max([Date]))"} >}  Volume*[Rate])

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.