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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Shell64
Regular Visitor

Doing percentage based on matrix row total and grouping row under it

Hi I have the below problem, what I want to do is a measure that will update with slicer year/month being select by user an caluate the percentage each grouping is based on the month grand total. So in January there was a total of 140 and 80 in group 1 is 57% of that.

Thanks

January  
Group 18057%
Group 2107%
Group 35036%
February  
Group 12022%
Group 21011%
Group 36067%
March  
Group 12020%
Group 23030%
Group 35050%
1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Shell64 ,

You can create a measure as below to get it:

Measure =
VAR _year =
    SELECTEDVALUE ( 'Yourtable'[Date].[Year] )
VAR _monthno =
    SELECTEDVALUE ( 'Yourtable'[Date].[MonthNo] )
VAR _per =
    SUM ( 'Yourtable'[Value] )
VAR _group =
    CALCULATE (
        SUM ( 'Yourtable'[Value] ),
        FILTER (
            ALLSELECTED ( 'Yourtable' ),
            YEAR ( 'Yourtable'[Date] ) = _year
                && MONTH ( 'Yourtable'[Date] ) = _monthno
        )
    )
RETURN
    DIVIDE ( _per, _group )

If the above one can't help you get the expected result, please provide some raw data in your table (exclude sensitive data) with Text format and the relationship info between the tables. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

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

View solution in original post

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hi @Shell64 ,

You can create a measure as below to get it:

Measure =
VAR _year =
    SELECTEDVALUE ( 'Yourtable'[Date].[Year] )
VAR _monthno =
    SELECTEDVALUE ( 'Yourtable'[Date].[MonthNo] )
VAR _per =
    SUM ( 'Yourtable'[Value] )
VAR _group =
    CALCULATE (
        SUM ( 'Yourtable'[Value] ),
        FILTER (
            ALLSELECTED ( 'Yourtable' ),
            YEAR ( 'Yourtable'[Date] ) = _year
                && MONTH ( 'Yourtable'[Date] ) = _monthno
        )
    )
RETURN
    DIVIDE ( _per, _group )

If the above one can't help you get the expected result, please provide some raw data in your table (exclude sensitive data) with Text format and the relationship info between the tables. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
lbendlin
Super User
Super User

Read about REMOVEFILTERS.  Identify the total for each month by removing the group filter, and then divide the current value by that. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Top Kudoed Authors