Forum Discussion

waeltken's avatar
waeltken
Icon for Helper I rankHelper I
4 years ago
Solved

TREATAS to filter multiple columns in combination

To the PBI Community,   My HR model has a pretty wide and long effective dated table of user records. It includes all historical user records for the past 6 years. I have a series of measures which...
  • Whitewater100's avatar
    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.