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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
xyz20
Contributor II
Contributor II

Issue in creating measure for bar chart year on year trend - Visualization

(count(
    {$<CUSTOMER_ACCOUNT = e({$<FISCAL_YEAR = {"$(=Max(FISCAL_YEAR))"}>}) , 
    FISCAL_YEAR = {"$(=Max(FISCAL_YEAR)-1)"}>} 
    CUSTOMER_ACCOUNT
) / 
count(
    {$<FISCAL_YEAR = {"$(=Max(FISCAL_YEAR)-1)"}>} 
    CUSTOMER_ACCOUNT
))

I want this measure in Bar chart as Year-On-Year Analysis, and want to show all the Years on X-axis.

Currently it is only showing the (Max(FISCAL_YEAR)-1) value on X-axis.

image.png

1 Reply
Kushal_Chawda

@xyz20  One option is to use chart level scripting. See here more about chart level scripting and how to enable it in app.

Create a bar chart with FISCAL_YEAR as dimension and sum(0) as measure. and put below script in script section. You might need to adjust the values depending on in which year you want to represent the values

 

//Gets the total no of rows in the current Chart or Table

Let r = HCNoRows();

//Looping through the rows (Year) to generate the value

For i = 1 to r

//Picks the value of the Year dimension to put it in set analysis measure

   Let vYear = HCValue(#hc1.dimension.1, i);
   Let vPrevYear = HCValue(#hc1.dimension.1, i)-1;

// Using above variable calculate measure 

   Let vValue = $(=count(
               {$<CUSTOMER_ACCOUNT = e({$<FISCAL_YEAR = 
               {"$(vYear)"}>}) , 
               FISCAL_YEAR = {"$(vPrevYear)"}>} 
               CUSTOMER_ACCOUNT) / 
               count(
               {$<FISCAL_YEAR = {"$(vPrevYear)"}>} 
               CUSTOMER_ACCOUNT));

 //Pushing the computed value to the measure 

   Put #hc1.measure.1(i) = $(vValue);
   
next