Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi all,
i have a data contain spend per company in different countries.
How do i write a dax formula to calculate number of top high spending company that contribute to 50% of total spend in each country?
Here is link to data example Percentage.xlsx
thanks,
Solved! Go to Solution.
Hi @ktt777 , hello Ashish_Mathur and elitesmitpatel, thank you for your prompt reply!
In order to calculate the number of high-expenditure companies that account for 50 per cent of total expenditures in each country, please try as following:
CumulativePercentage =
VAR CurrentCountry = MAX('Table'[Country])
VAR CurrentTotalSpend = MAX('Table'[TotalSpend])
VAR TotalSpendByCountry = CALCULATE(SUM('Table'[TotalSpend]), ALLEXCEPT('Table', 'Table'[Country]))
VAR RunningTotal = CALCULATE(
SUM('Table'[TotalSpend]),
FILTER(
ALLEXCEPT('Table', 'Table'[Country]),
'Table'[TotalSpend] >= CurrentTotalSpend
)
)
RETURN
DIVIDE(RunningTotal, TotalSpendByCountry, 0)
RowNumber = RANKX(ALLEXCEPT('Table','Table'[Country]),ABS([CumulativePercentage]-0.5),,ASC)
Total = CALCULATE('Table'[CumulativePercentage],FILTER('Table','Table'[RowNumber]=1))No of supplier =
VAR CurrentCountry = MAX('Table'[Country])
RETURN
IF(
[RowNumber] = 1,
RANKX(
FILTER(
ALL('Table'),
'Table'[Country] = CurrentCountry
),
'Table'[Percentage],
,
DESC,
DENSE
),
BLANK()
)
Result for your reference:
Best regards,
Joyce
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @ktt777 , hello Ashish_Mathur and elitesmitpatel, thank you for your prompt reply!
In order to calculate the number of high-expenditure companies that account for 50 per cent of total expenditures in each country, please try as following:
CumulativePercentage =
VAR CurrentCountry = MAX('Table'[Country])
VAR CurrentTotalSpend = MAX('Table'[TotalSpend])
VAR TotalSpendByCountry = CALCULATE(SUM('Table'[TotalSpend]), ALLEXCEPT('Table', 'Table'[Country]))
VAR RunningTotal = CALCULATE(
SUM('Table'[TotalSpend]),
FILTER(
ALLEXCEPT('Table', 'Table'[Country]),
'Table'[TotalSpend] >= CurrentTotalSpend
)
)
RETURN
DIVIDE(RunningTotal, TotalSpendByCountry, 0)
RowNumber = RANKX(ALLEXCEPT('Table','Table'[Country]),ABS([CumulativePercentage]-0.5),,ASC)
Total = CALCULATE('Table'[CumulativePercentage],FILTER('Table','Table'[RowNumber]=1))No of supplier =
VAR CurrentCountry = MAX('Table'[Country])
RETURN
IF(
[RowNumber] = 1,
RANKX(
FILTER(
ALL('Table'),
'Table'[Country] = CurrentCountry
),
'Table'[Percentage],
,
DESC,
DENSE
),
BLANK()
)
Result for your reference:
Best regards,
Joyce
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
In another tab of that file, show the expected result.
sorry i did not find the 2nd tab
That is not what i asked for. Create another tab and show the expected result there.
thank you.
what i can to see is for example below. there are 11 companies at the top contribute to 50% of total spend.
How to create formula to count to get 11 companies? There maybe can not find the exact 50% to total spend, but the closest to 50%
I have solved it please check the below file.
Percentage _solved
Please appreciate my work if it helps you.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 38 | |
| 36 | |
| 30 | |
| 28 |
| User | Count |
|---|---|
| 128 | |
| 88 | |
| 79 | |
| 67 | |
| 62 |