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
Anonymous
Not applicable

percentage by category

Hi,

 

I am using a simple table visual (direct query mode to a tabular model) and I want to display the percent values of a measure relative to a category subtotal (in my case it's the delivery number and Material:

 

Here's is an example of the data i have.

DeliveryMaterialQuantity
1abc20
2abc5
2def5
3xyz10

 

Now I want to add a column with the Qunatity percentages of Material by Delivery.

Delivery 1 Quantity 20 = 100% of Delivery Subtotal

Delivery 2 Quantity 5 for material abc is = 50% of Delivery Subtotal

Delivery 2 Quantity 5 for material def is = 50% of Delivery Subtotal

Delivery 3 Quantity 10 for material xyz is = 100% of Delivery Subtotal

 

Should look like this with Column Subtotal Percentag as desired outcome.

Delivery     Material QuantitySubtotal Percentage
1abc20100%
2 abc550%
2def550%
3xyz10100%

 

In the context menue of my table metric I can only chose: "Percentage of Grand Total" but that doesn't do the job.

Should be fairly simpel but I didn't find anything that solves it....

 

Any suggestions?

 

Thank you very much.

 

Lars

2 ACCEPTED SOLUTIONS
FrankAT
Community Champion
Community Champion

Hi @Anonymous ,

take a look at the following solution:

 

29-07-_2020_23-38-18.png

 Regards FrankAT

View solution in original post

v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

Create a measure as below:

Measure = 
var _counttoal=COUNTX(FILTER(ALL('Table'),'Table'[Delivery]=MAX('Table'[Delivery])),'Table'[Delivery])
var _countsub=COUNTX(FILTER(ALL('Table'),'Table'[Delivery]=MAX('Table'[Delivery])&&'Table'[Material]=MAX('Table'[Material])),'Table'[Delivery])
Return
DIVIDE(_countsub,_counttoal)

And you will see:

Annotation 2020-07-30 133550.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

Create a measure as below:

Measure = 
var _counttoal=COUNTX(FILTER(ALL('Table'),'Table'[Delivery]=MAX('Table'[Delivery])),'Table'[Delivery])
var _countsub=COUNTX(FILTER(ALL('Table'),'Table'[Delivery]=MAX('Table'[Delivery])&&'Table'[Material]=MAX('Table'[Material])),'Table'[Delivery])
Return
DIVIDE(_countsub,_counttoal)

And you will see:

Annotation 2020-07-30 133550.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
FrankAT
Community Champion
Community Champion

Hi @Anonymous ,

take a look at the following solution:

 

29-07-_2020_23-38-18.png

 Regards FrankAT

Greg_Deckler
Super User
Super User

@Anonymous - Sorry, not 100% following. Is the data source data, expected output? Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.