Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Leverage your QlikView investment to modernize BI – see how! Join Group
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator
Creator

Calculating possible values

Hi All,

I've been trying to solve this mystery for a while now.

I have a list of customers with their proposed Discount code and their discount codes used at transaction. So my end goal is to find the number of customers by month who have been using the proposed discount code (among multiple transaction discount codes if used).

sum(aggr(if(ProposedDiscCode= Concat(DISTINCT Transaction_Discount_Code, ','),1,0),Customer,Month,Store))

The above formula helps me identify the number but when the customer uses only the proposed discount code and none others.

CustomerProposedDiscCodeTransaction_Discount_Code
AdamIGIG,IH,IL
SnehaIHIH
TimIGIG
JoeIFIF,IG,IY

So my formula for the above table of values gives the count as 2, whereas I want 4.

Can you please help me with this.

Thanks in advance,

S

1 Solution

Accepted Solutions
Highlighted

Re: Calculating possible values

If this is how your data is, then try this

=Count(DISTINCT If(Transaction_Discount_Code = ProposedDiscCode, Customer))


Capture.PNG

View solution in original post

10 Replies
Highlighted

Re: Calculating possible values

May be try this

Sum(If(SubStringCount(Transaction_Discount_Code, ProposedDiscCode) > 0, 1, 0))

Highlighted

Re: Calculating possible values

or this

Sum(If(Index(Transaction_Discount_Code, ProposedDiscCode), 1, 0))

Highlighted
Creator
Creator

Re: Calculating possible values

Hi Sunny,

Can the expression be enabled to look at distinct transaction discount codes used? because in a month they may have multiple transactions and your formula calculates it at that level.

Thanks

S

Highlighted

Re: Calculating possible values

I am not sure I understand... but may be this

Sum(Aggr(If(SubStringCount(Transaction_Discount_Code, ProposedDiscCode) > 0, 1, 0), Customer, Month, Store))

Highlighted
Creator
Creator

Re: Calculating possible values

Hi Sunny,

It gives the same value as my expression above.

Highlighted

Re: Calculating possible values

Would you be able to provide a sample where you have Month and Store with expected output from the sample provided?

Highlighted
Creator
Creator

Re: Calculating possible values

Hi Sunny,

I have given a sample data.

My formula gives the total correct disc code customers to be 5, but the actual correct discount code customers should be 9.

Highlighted

Re: Calculating possible values

If this is how your data is, then try this

=Count(DISTINCT If(Transaction_Discount_Code = ProposedDiscCode, Customer))


Capture.PNG

View solution in original post

Highlighted
Creator
Creator

Re: Calculating possible values

Hi Sunny,

This formula works.:) many thanks for helping me so quick.!

However, I fail to understand the logic behind this, can you please help me understand it?

Regards,

S