Forum Discussion
Adamkowalsky92
1 year agoFrequent Visitor
DAX Measure - Co-occurrences
Hi, I'm having trouble coming up with a measurement. Simple table, 2 columns, Invoice No. and Product. The task is to obtain the result of co-occurrences on one invoice. I want to have a slicer ...
- 1 year ago
You'd need to create a separate table for use in the slicer. You can use
Product for slicer = DISTINCT( 'Table'[Product] )Do not connect that to the main table, just use it in the slicer.
You can then create a measure like
[Num co-occurences] = IF( SELECTEDVALUE('Product for slicer'[Product]) <> SELECTEDVALUE('Table'[Product]), VAR InvoicesForChosenProduct = CALCULATETABLE( VALUES('Table'[Invoice no.]), TREATAS( VALUES('Product for slicer'[Product]), 'Table'[Product] ) ) VAR InvoicesForCurrentProduct = VALUES('Table'[Invoice no.]) VAR Result = COUNTROWS(INTERSECT( InvoicesForChosenProduct, InvoicesForCurrentProduct )) RETURN Result )and use the [Product] column from the main table in your visual.
johnt75
Super User
1 year agoYou'd need to create a separate table for use in the slicer. You can use
Product for slicer = DISTINCT( 'Table'[Product] )
Do not connect that to the main table, just use it in the slicer.
You can then create a measure like
[Num co-occurences] = IF(
SELECTEDVALUE('Product for slicer'[Product]) <> SELECTEDVALUE('Table'[Product]),
VAR InvoicesForChosenProduct = CALCULATETABLE(
VALUES('Table'[Invoice no.]),
TREATAS(
VALUES('Product for slicer'[Product]),
'Table'[Product]
)
)
VAR InvoicesForCurrentProduct = VALUES('Table'[Invoice no.])
VAR Result = COUNTROWS(INTERSECT(
InvoicesForChosenProduct,
InvoicesForCurrentProduct
))
RETURN
Result
)
and use the [Product] column from the main table in your visual.
- Adamkowalsky921 year agoFrequent Visitor
Great, great, great! Exactly what i want! Thank you so much.