qliksenseqlik-expression

Reuse expression in QlikSense


I have a lengthy expression like this:

$(vUseHotlist) * number_of_bids_from_hotlist + 
$(vUseStocklist) * number_of_bids_from_stocklist + 
$(vUseDashboard) * number_of_bids_from_dashboard

I want to use this in multiple charts, and I tried defining it in a master element, but I cannot get it to work.

I want to avoid copy and pasting the code everywhere, because it becomes unreadable. Any ideas how to solve it? I have found information on how to use aggregated master elements (e.g. with a sum() function), but not for unaggregated expressions.

FYI, the variables used above are all either 0 or 1.

Thanks.


Solution

  • After a lot of trial and error I was able to resolve it. Instead of using master elements measures for this, you should define a variable with the code.

    Then you can use it like this in a graph.

    Sum($(MYVARNAME))