Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I have a table with the following sample data (first 3 columns) in Qlik Sense.
What expression can give me the 4th column? Basically I am trying to search in the same table for a row with the same User ID as the current row, and a transaction type of 'Sale'.
| Date | User ID | Transaction Type | Does this user ID have a sale? |
| 2/15/2021 | 3 | Sale | 1 |
| 2/13/2021 | 4 | Lead | 0 |
| 2/11/2021 | 5 | Sale | 1 |
| 1/20/2021 | 3 | Lead | 1 |
| 1/18/2021 | 5 | Lead | 1 |
Thanks in advance, I can't work this one out!
Hi,
this expression should work for you
count(aggr(if(MaxString(total<[User ID]>[Transaction Type])='Sale' , Date ),Date,[User ID]))
Hello - thanks for your help.
This doesn't appear to be working for me. Returns 0 for all rows.
If i try to break it down and make a measure with only this part:
MaxString(total<[User ID]>[Transaction Type])
Then it always returns 'Lead' for every row
By the way, for my real data the expression looks like this:
count(aggr(if(MaxString(total<user_id>type)='subscription' , [billing_changes.created_at] ),[billing_changes.created_at],user_id))
How can I figure out what i'm doing wrong? Have been messing with this one for a few days hehe
the strange thing is this part
MaxString(total<[User ID]>[Transaction Type]), should return subscription as s is coming after l can you check if you have some leading spaces or something
For my real data it's 'trial' and 'subscription'.
There are also other types as well.. sorry I didn't know it would affect the formula!
Surely you values will matter for an expression to work. I would recommend a slightly different calculation that eliminates the if-statement and string-comparison, instead using set anlaysis.
sum(total <[User ID]> aggr(Count(distinct{<[Transaction Type] = {'Sale'}>} 1), [User ID]))