Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BeautifulDash
Frequent Visitor

Matrix: group by measures (link between table with categorised measure names and actual measures)

I'd like a matrix with all the calculated measures for rows, subdivided, and the quarters of the year as columns.

I have a separate table with a hierarchy between Category and Subcategory for the measures, and the rows are displaced correctly. 
I also wrote the measures, and they calculate correctly. 
Grouping per quarter works, as I have a dedicated Date table that links with the Date column in the Incidents table, usual for time intelligence functions.
How can I however link the Subcategories to the measures with the exact same name to group?

I thought to add a calculated table but one formula for the different calculations per each row is not feasible (number of, ratio, ..).

 

 Q1Q2Q3Q4
Category: Incidents    
Subcategory: Number of IncidentsNumber of Incidents as a measure   
Subcategory: Number of Investigations    
Subcategory: Ratio of Incidents to Investigations    
6 REPLIES 6
BeautifulDash
Frequent Visitor

Thank you, that worked well.

How can I build a hierarchy for my measures used, so I can drill down in the matrix?

For instance:
+ Calculations for Product Categories

-- Calculations for Cars

-- Calculations for Laptops

+ Calculations for Non-Product Categories

-- Calculations for Employees

-- Calculations for Stores

Hi @BeautifulDash ,

 

You need to correspond the categories to the subcategories, like this:

 

vkkfmsft_0-1651633098565.png

 

Then use different measures for different levels.

 

Measure = 
SWITCH (
    TRUE (),
    ISINSCOPE ( 'Table'[SubCategory] ), [Measure2],
    ISINSCOPE ( 'Table'[Category] ), [Measure1],
    [Measure3]
)

vkkfmsft_1-1651633162802.png

 

Best Regards,
Winniz


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you very much for replying.

I think this approach only works when one measure (for instance, a simple division) is applied across all drilled-down categories, whereas I am trying to use one specific measure per drilled-down subcategory.

 

To illustrate; how I attempted to solve it, but I cannot seem to add this to a matrix to display correctly:

 

Untitled.png

Hi @BeautifulDash ,

 

Please try the following formula:

 

MatrixMeasure = 
CALCULATE (
    SWITCH (
        TRUE (),
        ISFILTERED ( 'Table'[SubCategory] ),
            SWITCH (
                MAX ( 'Table'[SubCategory] ),
                "SUBCAT A", SWITCH ( MAX ( 'Table'[Index] ), 1, [Pro_SubCat_A], 6, [NonPro_Category] ),
                "SUBCAT B",
                    SWITCH (
                        MAX ( 'Table'[Index] ),
                        2, [Pro_SubCat_B_1],
                        3, [Pro_SubCat_B_2],
                        4, [Pro_SubCat_B_3],
                        5, [Pro_SubCat_B_4],
                        7, [NonPro_SubCat_B_1],
                        8, [NonPro_SubCat_B_2],
                        9, [NonPro_SubCat_B_3]
                    )
            ),
        ISINSCOPE ( 'Table'[Category] ),
            SWITCH (
                MAX ( 'Table'[Category] ),
                "Product", [Pro_Category],
                [NonPro_Category]
            )
    ),
    TREATAS ( VALUES ( 'Table'[Category] ), 'Fact'[Category] ),
    TREATAS ( VALUES ( 'Table'[SubCategory] ), 'Fact'[SubCategory] )
)

vkkfmsft_0-1651740562647.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Many thanks for your excellent feedback.

What is the Fact table you are referring to? I do not understand the second parameter of the TREATAS DAX functions. 

And how do you build the above matrix using the measure? Quarters is columns but is MatrixMeasure rows or values?

v-kkf-msft
Community Support
Community Support

Hi @BeautifulDash ,

 

I am not sure if I understood your question correctly. If you want to display the measures as rows as in the figure below, then you can enable the "Switch values to rows" option in the Values pane.

 

vkkfmsft_2-1651216039868.png

vkkfmsft_1-1651215790489.png

 

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.