Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Morning,
I've been tasked with answering the questions "How many transactions contain only Card?" & "How many transactions contain Card & Party?" etc.. Due to the sheer amount of rows, I've been reccomended to use BI for this analysis, a tool I'm new to. I've attached a sample snippet of the available data and relationships below:
There are often numerous "Category Splits" within a transaction, so I'm needing to write a new column that combines all the Category splits to their transaction number, which can then be used to define how many are Card only etc.. Any advice on a measure that may be able to achieve this (With the data available) would be much appreciated?
Thanks in advance!!
Solved! Go to Solution.
I think you could tweak it to
Num matching transactions =
VAR NumSelectedCategories =
COUNTROWS ( VALUES ( 'Categories'[Category Split] ) )
VAR Transactions =
ADDCOLUMNS (
VALUES ( 'Line Level Transactions'[Transaction] ),
"@all items",
CALCULATE (
COUNTROWS ( DISTINCT ( 'Line Level Transactions'[Category split] ) )
),
"@selected items",
CALCULATE (
COUNTROWS ( DISTINCT ( 'Line Level Transactions'[category split] ) ),
TREATAS (
VALUES ( 'Categories'[Category Split] ),
'Line Level Transactions'[Category Split]
)
)
)
VAR Result =
COUNTROWS (
FILTER (
Transactions,
[@all items] = NumSelectedCategories
&& [@selected items] = NumSelectedCategories
)
)
RETURN
Result
First create a table to use in a slicer, like
Categories = DISTINCT( 'Line Level Transactions'[Category Split])
but do not link this to your transactions table, leave it disconnected. Then you can create a measure like
Num matching transactions =
VAR NumSelectedCategories =
COUNTROWS ( VALUES ( 'Categories'[Category Split] ) )
VAR Transactions =
ADDCOLUMNS (
VALUES ( 'Line Level Transactions'[Transaction] ),
"@all items", CALCULATE ( COUNTROWS ( 'Line Level Transactions' ) ),
"@selected items",
CALCULATE (
COUNTROWS ( 'Line Level Transactions' ),
TREATAS (
VALUES ( 'Categories'[Category Split] ),
'Line Level Transactions'[Category Split]
)
)
)
VAR Result =
COUNTROWS (
FILTER (
Transactions,
[@all items] = NumSelectedCategories
&& [@selected items] = NumSelectedCategories
)
)
RETURN
Result
which will return the number of transactions which consist only of the selected combination of categories.
Thank you for this John, really appreciate the support! The solution looks to be working correctly for situations in which there is 1 item in a transaction e.g Selecting "Card" in the slicer brings back all transactions that have one card in the basket.
However, if there are multiple items in one transaction, these look to be miss-assigned to the incorrect Category Splits, please see example below:
Don't suppose you have any further ideas to ammed this please?
Thank you!
I think you could tweak it to
Num matching transactions =
VAR NumSelectedCategories =
COUNTROWS ( VALUES ( 'Categories'[Category Split] ) )
VAR Transactions =
ADDCOLUMNS (
VALUES ( 'Line Level Transactions'[Transaction] ),
"@all items",
CALCULATE (
COUNTROWS ( DISTINCT ( 'Line Level Transactions'[Category split] ) )
),
"@selected items",
CALCULATE (
COUNTROWS ( DISTINCT ( 'Line Level Transactions'[category split] ) ),
TREATAS (
VALUES ( 'Categories'[Category Split] ),
'Line Level Transactions'[Category Split]
)
)
)
VAR Result =
COUNTROWS (
FILTER (
Transactions,
[@all items] = NumSelectedCategories
&& [@selected items] = NumSelectedCategories
)
)
RETURN
Result
Brilliant that's worked now, thank you!!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 24 | |
| 12 | |
| 11 | |
| 9 | |
| 8 |