Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Kafka_polka_dot
Contributor III
Contributor III

Flag build with 2 master measures is not working

Hi dear members of the Qlik community,

could you please help me to troubleshoot the issue with a dimension built using master measures?

The first master measure represents month-to-date sum of sales (MTD), taken from the alternate state 1 (set by a filter).

 

 

Sum({[1]<Order_date={">=$(=Date(MonthStart(Max(Order_date)), 'YYYY-MM-DD'))<=$(=Max(Order_date))"}>} sales)

 

 

 The second measure represents the sum of sales for the previous 3 months before the current month taken from the alternate state 1 (PM-3):

 

 

Sum({[1]<Order_date={">=$(=Date(MonthStart(AddMonths(Max(Order_date), -3)), 'YYYY-MM-DD'))<=$(=Date(MonthEnd(AddMonths(Max(Order_date), -1)), 'YYYY-MM-DD'))"}>} sales)

 

 

 My plan was to build a dimension with a flag to show the new customers:

 

 

IF(([MTD]>0 and [PM-3] = 0), 'J', 'N')

 

 

 The measures are working as expected, when I put them in a table with default state. But the dimension outputs only 'N', which is not correct.

Could you please tell, what do I miss here? Why is not this flag working?

Labels (2)
1 Solution

Accepted Solutions
rubenmarin

If flag is a dimension maybe you need to add an Aggr() to calculate it by each of the kundennr, not globally, like:

Aggr(IF(([MTD]>0 and [PM-3] = 0), 'J', 'N'), kundennr)

 

View solution in original post

4 Replies
rubenmarin

Hi, have you tried to set a table with both master measures and the flag expression? Is there any with MTD>0 and PM-3=0 and still the 3rd expression shows N?

Kafka_polka_dot
Contributor III
Contributor III
Author

Hi Rubenmarin,

thanks for reply. Yes, when I create a table with both master measures and the flag, I see a plenty of examples when MTD >0 and PM-3 = 0, which are marked as 'N'. 

Kafka_polka_dot_0-1720511763883.png

 

rubenmarin

If flag is a dimension maybe you need to add an Aggr() to calculate it by each of the kundennr, not globally, like:

Aggr(IF(([MTD]>0 and [PM-3] = 0), 'J', 'N'), kundennr)

 

Kafka_polka_dot
Contributor III
Contributor III
Author

It works now! I didn't even think about aggregation in this case. Thank you very much!