Forum Discussion
TREATAS to filter multiple columns in combination
- 4 years ago
Hi Henrik:
You can use TREATAS if you can’t change data model. TREATAS can be continued for all the in common columns between the fact tables. INTERSECT and CONTAINS are the two other options for using DAX to move filters. (I guess USERELATIONSHIP in a way too) None are great for performance. A typical use case for TREATAS could be (notice common columns)
Sales =
CALCULATE(
SUMX( Sales, Sales[Quantity] * Sales[Unit Price]),
TREATAS(VALUES(Purchases[Brand], Sales[BrandName]),
TREATAS(VALUES(Purchases[Color], Sales[ColorName])So this is used in the case where two fact tables exist with no relationships. We make a report for purchases by brand using columns from Purchases and then use TREATAS to get Sales amount for same report.
Sales[Brand])The way to normally solve this is to create middle table that joins these two fact tables as they both have product info.
E.G.,
Products = DISTINCT(
UNION(
ALL(Purchases[Product Name]), Purchases[Color]),
ALL(Sales[Product Name]), Sales[Color])
))I hope this answers your question.
"I know TREATAS can filter multiple columns, but can/does TREATAS apply filters in combination with each other so that only those rows are returned where the unique combination of [User ID], [Event Date] and [Last Modified Date] are true?"
When in doubt about how something works, it's always good to consult documentation: TREATAS - DAX Guide