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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Adfc_NZ
Contributor III
Contributor III

Add "National" to dataset that only has Regions

Hi,

I have a set of transactional data that uses a dim table with the regions. All good here, nothing special.

Issue is, the customer wants a barchart with an "extra" bar representing the "national", i.e. the totals.

I need your help and advise on this, because as I can see it, I have 2 options:

1- Summarise the data in the load script and concatenate it back to the fact with the "Region" being "National"

A few pros and cons, the major con imo is the fact that I'd then need to exclude "National" from all other areas of the app where "National" is not needed

2- Create a Dimension with the list of the Regions + "National", then in a measure in the chart to display each region + the national, use "Pick(Match(" along with 1 Set Analysis per region (that actually exist in the dataset) plus another where "Region=" then sums the amount.

This works very well, but the major con is that because of the Set Analysis the Region filter no longer works on this visual.

I am inclined to go with option 2, but just wondered if anyone here has a different solution to this requirement which might be more "flexible" than the 2 above?

Thank you.

Labels (2)
12 Replies
Adfc_NZ
Contributor III
Contributor III
Author

I tried adding the following:

Let vRegionSelectedCount = GetSelectedCount(Region);

 

And then wrap the "Add Load" inside an if:

If $(vRegionSelectedCount)= 0 then
For J = 1 to P
Let vTotalSales = vTotalSales + HCValue(#hc1.measure.1, J);
Next


Add Load
'National' as Region, //Country is dimension Label.
$(vTotalSales) as 'Budget ($)' //Sales is measure Label.
Autogenerate 1;
end if

 

But this doesn't work:
Screenshot 2025-10-30 212532.png

What am I doing wrong? Or is this not even possible?

hanna_choi
Partner - Creator II
Partner - Creator II

Hi @Adfc_NZ 

I succeeded by changing the script as follows.

I have found that GetSelectedCount(Region) is not calculated.
So I set it as a variable to receive it as a constant value.

************

Let vRegionSelectedCount = $(vCountCountry);
Let P = HCNoRows();
If $(vRegionSelectedCount)= 0 then
For J = 1 to P
Let vRegionSelectedCount = vRegionSelectedCount + HCValue(#hc1.measure.1, J);
Next


Add Load
'National' as Country,
$(vRegionSelectedCount) as 'Budget ($)'
Autogenerate 1;
end if

**********************

hanna_choi_2-1761869333678.png

 



 

hanna_choi_0-1761869185496.png

hanna_choi_1-1761869265939.png

 

***If I select Canada, the chart is display only canada and 'National' is disappear.

 

hanna_choi_3-1761869388189.png

 

 

Adfc_NZ
Contributor III
Contributor III
Author

Hi @hanna_choi,

Great idea, calculate the SelectedCount outside and then pass it into the script, love it! 🙂

Thank you for your time, this solution will work brilliantly.

And thanks also to everyone who contributed with ideas! 🙂