Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

david_____p
New Contributor II

Count(TOTAL <[Master Dimension]> Product)

If possible can someone point me at documentation explaining why this works even though there is an error in the expression editor?

Given that I have a master dimension as "Master Dimension"

The measure for my chart is:

Count(Product)/Count(TOTAL <[Master Dimension]> Product)

I get this error

Bad field name: [Master Dimension]

But the the chart still renders and saves normally.

My chart has two dimensions the first is "Master Dimension" and the second is "Product". For a Customer each Product should have it's own bar in the chart. The bar represents the percentage of time that product appears for that customer. For Astrida AA appears twice and she has 3 product rows so that's 66.7%. The graph displays as expected but I can't explain why.

I've attached a simple app. That demonstrates the issue. Here is the load script if needed.

ProductData:

LOAD * inline [

Customer|Product|UnitSales|UnitPrice

Astrida|AA|4|16

Astrida|AA|10|15

Astrida|BB|9|9

Betacab|BB|5|10

Betacab|CC|2|20

Betacab|DD||25

Canutility|AA|8|15

Canutility|CC||19

] (delimiter is '|');

1 Solution

Accepted Solutions
david_____p
New Contributor II

Re: Count(TOTAL <[Master Dimension]> Product)

TL;DR Use the load script to Change the name of the field.

Ah, figured it out. We use the master dimension so that we could have clean names for displayed above the selected filters and the use of LTrim was part of that. When the master dimensions was just the field it would not use the label but when the dimension was a formula it used the label.

Now in the load script we can load the field as "Master Dimension" and it will have a nice label when when to filter the selection.

4 Replies

Re: Count(TOTAL <[Master Dimension]> Product)

Syntax editor doesn't always understand all the syntax... but the fact that it works is something I would have not expected. It am not sure if this will even work if Master Dimension was an if statement instead of just =LTrim(Customer)

david_____p
New Contributor II

Re: Count(TOTAL <[Master Dimension]> Product)

I'm hesitant to use this in a production app. I'm wondering if you see a better way to achieve the same result?

Re: Count(TOTAL <[Master Dimension]> Product)

May be this

Count(Product)/Count(TOTAL <Customer> Product)

or this

Count(Product)/Aggr(NODISTINCT Count(Product), Customer)

david_____p
New Contributor II

Re: Count(TOTAL <[Master Dimension]> Product)

TL;DR Use the load script to Change the name of the field.

Ah, figured it out. We use the master dimension so that we could have clean names for displayed above the selected filters and the use of LTrim was part of that. When the master dimensions was just the field it would not use the label but when the dimension was a formula it used the label.

Now in the load script we can load the field as "Master Dimension" and it will have a nice label when when to filter the selection.

Community Browser