Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
angelfer90
Contributor
Contributor

Variables, select date dimensions and calculation (bar chart)

Hello to everybody,

 

I had a bar chart, with one data dimension "[Purchase_Order_Date.autoCalendar.YearMonth]" 

and one measure 
=COUNT(Resultado)/COUNT(TOTAL <[Purchase_Order_Date.autoCalendar.YearMonth]> Resultado)

As you can see in the image, the graph shows the percentage of each YearMonth, inside each YearMonth, so each YearMonth always is 100% adding the 3 options.

angelfer90_0-1652960970963.png

 

Later I add variables to this Bar Chart (something I done before), in order to give users the possibility to explore this bar chart with differente date dimensions.

The variable is declare with this code:
set vTipoDimensionFecha = string;

and I allow the user to choose the value of the variable with these graph object:

angelfer90_1-1652961487006.png

 



But the problem in this case is that the measure is not doing which I intend, which is to calculate the % of each option inside particular dates, for example YearQuarter, YearWeek, etc.

 

I tried differente formulas for the measure but all of them fail:

=COUNT(Resultado)/COUNT(TOTAL <$(vTipoDimensionFecha)> Resultado)
//=COUNT(TOTAL <$(vTipoDimensionFecha)> Resultado)/COUNT(TOTAL <$(vTipoDimensionFecha)> Resultado)
//=COUNT(Resultado)/COUNT(TOTAL <[Purchase_Order_Date.autoCalendar.YearQuarter]> Resultado) --the same used before

 

As you can see in this image, instead of calculate the % inside each yearquarter, it did for the total.

angelfer90_2-1652961549537.png

 

I guess that the problem has to be in the measure code, but I´m not sure,

 

Any ideas?

 

Thank you in advance

Labels (3)
1 Reply
edwin
Master II
Master II

if you use  $(vTipoDimensionFecha) as your date dimension as well the bar chart should adjust.  and if you are already doing that then theres something else causing the issue.  maybe post some sample data