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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
dnguyen67
Frequent Visitor

How to calculate and show the 100% percentage of each category in each month

Hi all,

How can I calculate the measure to show the percentage of each category with total 100% each month, not 100% over the time period?

For example, here is the chart with top 5 categories

dnguyen67_1-1651528073495.png

 when I convert the data into the percentage, they shows the percentage of each category as 100% total over all time, but I want to show percentage of total in each month.

dnguyen67_0-1651527996545.png

Yes, I can use 100% stacked column chart, but I need the line chart in this case. Is it possible? even I have to do some extra measure fields or columns

 

Thanks,

 

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @dnguyen67 ,

 

I created some dummy data based on your screenshots and made a solution.

Sample data:

vstephenmsft_0-1651717513384.png

I reproduced your outputs.

vstephenmsft_1-1651717564692.png

vstephenmsft_2-1651717578577.png

 

Now here's my solution.

1.Create a month column, a year column and a sort column.

Month = FORMAT([Date],"MMM")
Year = YEAR([Date])
sort = MONTH([Date])

vstephenmsft_3-1651717758336.png

 

2.Sort the month column by the sort column.

vstephenmsft_4-1651717779563.png

 

3.Create a measure to calculate the percentage by category per month.

Percentage =
VAR _sum =
    SUM ( 'Table'[Value] )
VAR _totalpermonth =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            [Year] = MAX ( 'Table'[Year] )
                && [Month] = MAX ( 'Table'[Month] )
        )
    )
RETURN
    DIVIDE ( _sum, _totalpermonth )

 

4.Here's the expected output.

vstephenmsft_5-1651717888019.png

 

You can check more details from my attachment.

 

 

Best Regards,

Stephen Tao

 

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-stephen-msft
Community Support
Community Support

Hi @dnguyen67 ,

 

I created some dummy data based on your screenshots and made a solution.

Sample data:

vstephenmsft_0-1651717513384.png

I reproduced your outputs.

vstephenmsft_1-1651717564692.png

vstephenmsft_2-1651717578577.png

 

Now here's my solution.

1.Create a month column, a year column and a sort column.

Month = FORMAT([Date],"MMM")
Year = YEAR([Date])
sort = MONTH([Date])

vstephenmsft_3-1651717758336.png

 

2.Sort the month column by the sort column.

vstephenmsft_4-1651717779563.png

 

3.Create a measure to calculate the percentage by category per month.

Percentage =
VAR _sum =
    SUM ( 'Table'[Value] )
VAR _totalpermonth =
    CALCULATE (
        SUM ( 'Table'[Value] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            [Year] = MAX ( 'Table'[Year] )
                && [Month] = MAX ( 'Table'[Month] )
        )
    )
RETURN
    DIVIDE ( _sum, _totalpermonth )

 

4.Here's the expected output.

vstephenmsft_5-1651717888019.png

 

You can check more details from my attachment.

 

 

Best Regards,

Stephen Tao

 

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

Ashish_Mathur
Super User
Super User

Hi,

Try this measure

=divide([Total sales],calculate([Total sales],allselected(Data[Category])))

If this does not work, then share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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 MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.