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

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Giuseppe_Alleruzzo
Contributor II
Contributor II

Filter a variable value

Hi guys, i've a problem. In my project i've many things to sum and all of them give results by year, month and day.

To simplify my scripts i created a variable "v_total_count" with inside it sum(A) + sum(B) + Sum(C) ....+ Sum(Z)

Now I want to create a chart with months as rows and total count for specific years as columns.

How can i do this without filtering dimensions in my dashboard?

For example as first column i'd like to have count month by month for year 2024

if i have an expression i do Sum({$<Year {'2024'}>}A)

What do i have to do to have the same filter for a variable?

Thank you so much

Labels (1)
14 Replies
Clement15
Partner - Specialist
Partner - Specialist

I'm working on the Qlik Sense SaaS version, and I don't have this. I don't know if it's from the version. But be careful not to forget the = in the measure.

Giuseppe_Alleruzzo
Contributor II
Contributor II
Author

I think the same thing, it could depend from the version. I work on QV 12. I put the = into the measure but it's not the problem.

What do you suggest as an alternative to the variable if you have to sum 15 dimensions all together to have the total for every day, month or year and use it for another chart?

A,B,C... are different things and have different sources (into the script i have a load for A from a DB,  a load for B from another DB...)

I can't write everytime Sum(A) + Sum(B) + ...Sum(X).

Thank you so much for the answer

marcus_sommer

AFAIK is the above suggested outer set analysis only within the latest releases of QV12 available. The syntax-highlighter has some restriction but it hints in the direction that your release didn't know the feature already.

Beside this you should check the variable-interpretation independent of the the set analysis - and if it's not working you may change: $(v_test) to $(=v_test)

Further you may include the set analysis as parameter within the variable, maybe in this (simplified) way:

set v = "sum($1 rangesum(A, B,C))"

and then calling the variable like:

$(v({< Year = {2024}>}))

Note: the rangesum() is quite the same like A + B + C without returning an error if any of the values isn't a number and it's not always the same as sum(A) + sum(B) + sum(C) but within the most scenarios it will return the wanted results.

Independent of the above it seems that your measure-fields have a crosstable-structure which is often very painful to handle. Better is mostly to transform the data-set per: The Crosstable Load - Qlik Community - 1468083.

Giuseppe_Alleruzzo
Contributor II
Contributor II
Author

Hi Marcus, I tried but filter doesn't work. I created two expressions, the first without filter (so I have totale volumes of 2022,2023 and 2024), and the second with filter as you suggest (2024). The result is the same for the two expressions

Giuseppe_Alleruzzo_0-1708690640563.pngGiuseppe_Alleruzzo_1-1708690678248.png

Giuseppe_Alleruzzo_2-1708690731672.png

I don't know why it doesn't work

 

marcus_sommer

Did you really creates a second variable which contained the mentioned parameter?

Beside this remove the expression-lable and then hoover with the mouse on them. In a popup you will see the applied expressions with a resolving of the variables. Does this expression really look like as if you had written it completely manual?