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.
ThxAlot
Super User
1 year agoIt's solved already when I saw it; but just for fun only, I provide a more sophisticated solution applicable to a more generic model. What's more an intricacy of it is that when more products selected in the slicer (ie, product 1&2), only those invoices (invoice 123 & 456) containing all selected products will be further investigated for co-existing products (product 3&4).