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
arp
Regular Visitor

Display percentage of filtered total in a line chart

 

Hi,

 

I'm trying to display the % of total sales for each groups name over a three year period but only where the country = X.

 

I can do this in a matrix using the percentage of column total function but am unable to display this in a line chart. Any suggestions how I might do this?

 

Group NameYearSalesCountry
A2015 X
A2016 X
A2017 X
B2015 y
B2016 y
B2017 y
C2015 X
C2016 X
C2017 X
D2015 X
D2016 X
D2017 X
E2015 y
E2016 y
E2017 y

 

Thanks

1 ACCEPTED SOLUTION

@arp

 

Sorry. I seem to have made a mistake in my previous post. Try this:

 

Measure =
DIVIDE (
    SUM ( Table[Sales] ),
    CALCULATE ( SUM(Table[Sales]), ALL ( Table1[Group Name] ) )
)

 

Code formatted with   www.daxformatter.com

View solution in original post

7 REPLIES 7
AlB
Super User
Super User

Hi @arp

 

I think you can do the same in a line chart. Place the [Group Name] in the x-axis and Sales in values and choose Show as Percentage.

Set [Country in a slicer to restrict the calculation to 'X'  

arp
Regular Visitor

Hi,

 

This hasn't worked for me. The group names have filtered to those in country X but the percentage values are still being calculating on total sales rather than just sales in country X...

 

Hi @arp,

 

By my tests, I'm afraid the option Percent of column total is only for matrix visual currently in Power BI as it has Column Field.

 

For other charts, it only has Percent of grand total. 

 

For your requirement, you'd better create a measure like AlB suggest to achieve that.

 

Best  Regards,

Cherry

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

@arp

 

OK, then let's try with a measure in the values of the chart:

 

Measure =
DIVIDE (
    SUM ( Table[Sales] ),
    CALCULATE ( Table[Sales], ALL ( Table1[Group Name] ) )
)

and still with [Country] in the slicer to select "X" (or any other)

arp
Regular Visitor

Thanks both for the replies.

 

I'm trying to set up the measure as suggested but I'm getting an error message saying that a single value for the sales column in the relevant table cannot be determined?

@arp

 

Sorry. I seem to have made a mistake in my previous post. Try this:

 

Measure =
DIVIDE (
    SUM ( Table[Sales] ),
    CALCULATE ( SUM(Table[Sales]), ALL ( Table1[Group Name] ) )
)

 

Code formatted with   www.daxformatter.com

arp
Regular Visitor

@AlB

 

That's better! Thank you for your help

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.