Forum Discussion

fpereira's avatar
fpereira
Regular Visitor
3 months ago
Solved

Matrix with dynamic years only for specific measures (hide other measures per year)

I have several metrics calculated and want to display them in a table or matrix view, but I want two of the metrics to show the values broken down by year. However, if I put the year in the columns, ...
  • Shai_Karmani's avatar
    3 months ago

    The matrix in Power BI applies a single column hierarchy to every value field, so natively you cannot have Year break down only some measures and not others inside one matrix.

     

    The cleanest workaround is to place two matrix visuals side by side, sharing the same row fields. One has Year on Columns with only your two year-broken-down measures, the other has no column field and contains the rest of the measures. Align their widths and hide the duplicate row header on the second one for a seamless look.

     

    If everything has to stay in one visual, you can wrap the non-year measures so they return BLANK when Year is in scope and the actual total when it is not, for example:

     

    Total Cost (no year) = IF(ISINSCOPE('Date'[Year]), BLANK(), [Total Cost])

     

    The year column headers will still appear but the cells will be empty for those measures. In practice the two-visual approach looks cleaner.

     

    If that was helpful, please give a thumbs up and mark it as resolved.

     

    Best regards,
    Shai Karmani

     

    Let's connect in LinkedIn