The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I'm doing a basket analysis and have 7 columns containing 7 items:
Is there a way to search for a specific item combination - say avacado, crackers, hummus, peroni - occuring in a transaction and set this combination as a variable? I'd then like to set a second variable as one of the seven items in column 6 in order to calculate the Support. I hope this makes sense.
Solved! Go to Solution.
Hello,
Yes, I'd like more help.
I unpivoted the columns and saved as .pbix file but I'm not sure how to include it in a post.
You first need to structure your data to look like this.
You can then use a measure like this in a table visual to get the result shown.
ContainsList =
VAR itemstofind = { "avocado", "crackers", "hummus", "peroni" }
VAR thisIDitems =
DISTINCT ( Transactions[Value] )
RETURN
IF ( COUNTROWS ( INTERSECT ( itemstofind, thisIDitems ) ) = 4, "Y", "N" )
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
You first need to structure your data to look like this.
You can then use a measure like this in a table visual to get the result shown.
ContainsList =
VAR itemstofind = { "avocado", "crackers", "hummus", "peroni" }
VAR thisIDitems =
DISTINCT ( Transactions[Value] )
RETURN
IF ( COUNTROWS ( INTERSECT ( itemstofind, thisIDitems ) ) = 4, "Y", "N" )
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Pat,
This worked - thank you so much!
Sarah
Yes, you can use the DAX function INTERSECT to do this kind of analysis. Before that you will want to bring your source data into a usable format, likely by unpivoting.
If you like more help please provide sanitized sample data in usable format (not as a picture - inserting it into a table would be good).
Hello,
Yes, I'd like more help.
I unpivoted the columns and saved as .pbix file but I'm not sure how to include it in a post.
Maybe this will work? Only the first 50 transactions (out of 1000) are included due to character limits in this post.
AttributeValue
|
User | Count |
---|---|
78 | |
77 | |
37 | |
32 | |
30 |
User | Count |
---|---|
92 | |
81 | |
58 | |
48 | |
48 |