The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I am new to Power BI. I need to build a DAX measure to sum a variable by group, and to get percentage inside each group.
For example:
| Nr | Name | Vendor Name | Quantity | % | Sum |
| 1 | Name1 | Vendor1 | 694 | 48.16% | 1441 |
| 1 | Name1 | Vendor2 | 397 | 27.55% | 1441 |
| 1 | Name1 | Vendor3 | 350 | 24.29% | 1441 |
| 2 | Name2 | Vendor4 | 450 | 100% | 450 |
I tried the following measure to get the sum by group, but the sum is not correct.
Total Quantity by Nr =
CALCULATE(
SUM('Table'[Quantity]),
ALLEXCEPT('Table', 'Table'[Nr])
)
Thanks for the help.
Solved! Go to Solution.
Hi, @larx_mandel
I created a measure using these two DAX expressions:
Total Quantity by Nr =
CALCULATE(
SUM('Table'[Quantity]),
ALLEXCEPT('Table', 'Table'[Nr])
)
Percentage by Nr =
DIVIDE(
SUM('Table'[Quantity]),
[Total Quantity by Nr],
0
)
I have uploaded the PBIX file of this example below for your reference.
If I have answered your question, please mark my reply as solution and kudos to this post, thank you!
Hi, @larx_mandel
I created a measure using these two DAX expressions:
Total Quantity by Nr =
CALCULATE(
SUM('Table'[Quantity]),
ALLEXCEPT('Table', 'Table'[Nr])
)
Percentage by Nr =
DIVIDE(
SUM('Table'[Quantity]),
[Total Quantity by Nr],
0
)
I have uploaded the PBIX file of this example below for your reference.
If I have answered your question, please mark my reply as solution and kudos to this post, thank you!