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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Username1848
Frequent Visitor

Calculate the share of a value over a subtotal in an Excel data model (DAX)

Hello all, my problem is the following.

 

I have a data sheet with the following columns:

  • The column "Plant" contains information in text.
  •  The column "Customer" contains information in text.
  • The column "Qty" contains the number of delivered parts and is a number.
  • The column "PN" contains the number of part numbers and is a text or number, but is interpreted as text.

One characteristic in “plant” can have several characteristics in “customer”

One characteristic in “Customer” can have several characteristics in “PN”.

 

I created a data model from this excel table (because I needed the "discrete count" for the pivot table field setting). In this data model I created a pivot table. The pivot table has the “plant” column and the “customer” column as lines, with the “plant” being the first column and “customer” being the second. In the values of the pivot I have the sum of “Qty” and the discrete count of “PN” for each characteristic of “customer” per characteristic of “plant”. I then created a measure called “Avg” that divides the column “Qty” by the column “ PN” per line, which gives me the average number of delivered parts per unique part number.

In this data model I want to create another measure in the pivot table. The measure shall divide the value of "Avg" per characteristic of "Customer" by the subtotal of the "Plant" column for all characteristics of "Customer".

 

How do I write this measure?

Please see the table below for visualization. The column "Share of Plant average (Measure)" is what I want to create with a measure in the pivot.

 

The measure "Avg Qty per PN (Measure)" is calculated by dividing "Sum of Qty" by "Count of PN". The measure I want to replicate in Excel data model / DAX is "Share of Plant average (Measure)". It is calculated by dividing the "Avg Qty per PN (Measure)" by the subtotal of the respective plant. In the first line, it's calculated by dividing 3.333 by 4.500.

 

PlantCustomerSum of QtyCount of PNAvg Qty per PN (Measure)Share of Plant average (Measure)
1A              10.000                            3                 3.33374%
1B              20.000                            5                 4.00089%
1C              15.000                            2                 7.500167%
1 subtotal               45.000                         10                 4.500 
2C              10.000                            8                 1.25057%
2D                 8.000                            5                 1.60073%
2E              15.000                            2                 7.500341%
2 subtotal               33.000                         15                 2.200 
3A                 9.000                            4                 2.250129%
3D              10.000                            8                 1.25071%
3F              13.000                            3                 4.333248%
3G              12.000                            9                 1.33376%
3 subtotal               35.000                         20                 1.750 

 

 

 

1 ACCEPTED SOLUTION

3 REPLIES 3
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

I changed the pictore with the actual table. At first I used a table, but it somehow was distorted after inserting, so I changed it to a screenshot. 

lbendlin_0-1717768530786.png

 

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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