Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Shilpa16
Contributor III
Contributor III

Results of measure using set analysis is not as per dimension

Hi Friends

I need your help. I have a requirement where I need to show the count of orders which are placed by different customers in different months in a table . I need to consider only those customers who are in target(Target_Flag=1) on each monthend date (like 30th june for the month of june)and then count the orders placed by these customers during that month.

For example:

Example Dataset:
Cust_IdOrder_IdDateIdTarget_Flag
15511-06-20191
17321-06-20190
14030-06-20191
12804-07-20190
17518-07-20191
14521-07-20191
15031-07-20190
25516-06-20191
21030-06-20190
23507-07-20190
25031-07-20191
32505-06-20191
34423-06-20191
32030-06-20191
35015-07-20190
32527-07-20190
33031-07-20190
 

Required result in table:

MonthYearOrders countExplanation
Jun-20196Cust_Id=1 and 3(Target_Flag=1 on 30th june)
Jul-20192Cust_Id=2(Target Flag =1 on 31st jul

 

So we need to consider the Target flag only on the monthend and based on that we have to count all the order_Id placed by that target cutomer during that month irrespective of the flag when the order was placed.

I am using the following expression at the moment for the same:

Aggr(count({<Cust_Id = P({<[Target_Flag] = {1},  Daily_Flag= {'M'} >})>} distinct Order_Id), MonthYear)

Daily_Flag is a flag  which I created to give  M for Monthend dates and D for rest other dates.

It is giving me wrong values when I select the MOnthYear filter then it gives me correct value. I want to see the correct value even without the month filter. Please suggest if somebody has a solution.

Thanks in Advance,

Shilpa

3 Replies
UserID2626
Partner - Creator III
Partner - Creator III

Remove count({<Cust_Id = P({<[Target_Flag] = {1},  Daily_Flag= {'M'} >})>} distinct Order_Id) in dimension.

In dimension just give [MonthYear] and measure = count({<Cust_Id = P({<[Target_Flag] = {1},  Daily_Flag= {'M'} >})>} distinct Order_Id)

JordyWegman
Partner - Master
Partner - Master

Hi Shilpa,

I don't really get your sample, but if you want to count the montends with a target flag to this:

Create a concatenated key based on Customer &'|'& Order (%CustOrder)

Use this formula:
Count( {$< Target_Flag = {1}, %CustOrder = {"=Floor(Date#(DateId,'DD-MM-YYYY')) = Floor(MonthEnd(Floor(Date#(DateId,'DD-MM-YYYY')))) "} >}Cust_Id &'|'&Order_Id)

Outcome:

2019-11-19 11_49_28-Qlik Sense Desktop.png

 

Jordy

Climber

Work smarter, not harder
Shilpa16
Contributor III
Contributor III
Author

Hi,

Many thanks for your reply.

My dimension is MonthYear and my measure is 

Aggr(count({<Cust_Id = P({<[Target_Flag] = {1},  Daily_Flag= {'M'} >})>} distinct Order_Id) ,MonthYear)

but this is not giving the desired result. I tried using your expression

count({<Cust_Id = P({<[Target_Flag] = {1},  Daily_Flag= {'M'} >})>} distinct Order_Id)

but still the same. Actually it is counting all the Cust_Id in that month who placed the order and were in target at any point of time not necessarily in that monthend. As sson as apply the filter for MonthYear it gives the correct result.