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.
Hi All, I have two measures created to show the Top 'N' and 'Others' in terms of highest profit but when added to my table neither column is able to produce a total for the column. Is it possible to add this in anyway?
The two measures are as per below;
Other =
VAR TopNumber =
IF( HASONEVALUE('TopN Filter'[TopN]),VALUES('TopN Filter'[TopN]),10)
VAR Rest =
DISTINCTCOUNT(Air[Parent Customer]) - TopNumber
RETURN
IF(
HASONEVALUE(CustomerName[Parent Customer]),
IF(
VALUES(CustomerName[Parent Customer]) = "Others",
SUMX(
TOPN(
Rest,
ADDCOLUMNS(
VALUES(Air[Parent Customer]),
"Measure",'Air Measures'[Total GP Air]
),
[Measure],ASC
),
[Measure]
)
)
)
Top X =
VAR TopNumber =
IF( HASONEVALUE('TopN Filter'[TopN]),VALUES('TopN Filter'[TopN]),10)
VAR Rest =
COUNTROWS (Air) - TopNumber
RETURN
IF(
HASONEVALUE(CustomerName[Parent Customer]),
CALCULATE(
[Total GP Air],
FILTER(
Air,
Air[Parent Customer] = VALUES(CustomerName[Parent Customer])
&& CONTAINS(
TOPN(
TopNumber,
ADDCOLUMNS(
ALL(CustomerName[Parent Customer]),
"Gross Profit", CALCULATE(
[Total GP Air],
FILTER(Air,Air[Parent Customer] = EARLIER(CustomerName[Parent Customer]))
)
),
[Gross Profit],DESC
),
CustomerName[Parent Customer],VALUES(CustomerName[Parent Customer])
))))
With the resulting table currently looking like this;
This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376
Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
@Gazsim44 can you try uploading the photo of table again, I can't see it.
What is the data type for the two measures? I haven't spent much time reading your full post to know if that's the problem, but that's one of the first things I'd check.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@AllisonKennedyBoth are set to whole number so I would hope this shouldnt be an issue?
Attached a copy of the table again.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
76 | |
74 | |
49 |
User | Count |
---|---|
146 | |
108 | |
106 | |
90 | |
62 |