Forum Discussion

Maximous89's avatar
Maximous89
Helper I
9 months ago
Solved

TREATAS

  Hello sharks,   i have tow columns inside one table (HIER[LEVEL_3_DESC],HIER[LEVEL_5_DESC]), they both have same valus as data points which is manufacturer name but with diffrent filter of H1 an...
  • DataNinja777's avatar
    9 months ago

    Hi Maximous89 ,

     

    You can use use treatas to achieve your required output.

    Since LEVEL_5_DESC (from H1) contains the values you want to map to LEVEL_3_DESC (in H3), treatas is the function which can move that lineage.

    Here is the refined measure. 

    Tested Solution = 
    VAR _SelectedLevel5 = VALUES(HIER[LEVEL_5_DESC])
    
    RETURN
    CALCULATE(
        [Avg of HANDNP],
        REMOVEFILTERS(HIER),             -- Remove existing context from the visual
        HIER[AC_HIERARCHY_CODE] = "H3",  -- Force the calculation to look at H3
        HIER[HLEVEL] = "MANUFACTURER",   -- Ensure we are looking at the right level type
        TREATAS(
            _SelectedLevel5,             -- Take the selection from the visual (e.g., "Toyota" from Level 5)
            HIER[LEVEL_3_DESC]           -- Apply it as a filter to Level 3
        )
    )

    The resultant output is as shown below:

     

    I have attached an example pbix file. 

     

    Best regards,