Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
I have this table:
I want to show only those brands with more than 2 distinct articles.
This measure works fine for all the numbers in the table, but total sum fails.
I was not able to adapt for Greg's solution.
Is there a DAX formula to do so?
Solved! Go to Solution.
I believe you want something like this, should have the right total:
Measure 2 =
VAR __Sales =
SUMMARIZE(articles,[Brand],"__Sales",SUM([Sales]),"__Count",COUNTX(DISTINCT(SUMMARIZE(articles,[Articles])),[Articles]))
RETURN
SUMX(FILTER(__Sales,[__Count]>2),[__Sales])
See attached, Page 2, articles table.
Hi,
Try these measures
Total sales = SUM(Data[Sales])
Number of articles = DISTINCTCOUNT(Data[Articles])
Measure = SUMX(FILTER(SUMMARIZE(VALUES(Data[Brand]),Data[Brand],"ABCD",[Number of articles],"EFGH",[Total sales]),[ABCD]>2),[EFGH])
Hope this helps.
Brand;Articles;Sales
A;Article1;4
A;Article2;2
A;Article1;2
A;Article1;5
B;Article3;10
B;Article3;105
B;Article3;26
C;Article1;24
C;Article2;27
C;Article3;85
C;Article4;63
D;Article5;15
D;Article5;45
E;Article5;65
E;Article2;35
E;Article2;85
E;Article2;91
E;Article1;10
Should be the result
Hi,
Try these measures
Total sales = SUM(Data[Sales])
Number of articles = DISTINCTCOUNT(Data[Articles])
Measure = SUMX(FILTER(SUMMARIZE(VALUES(Data[Brand]),Data[Brand],"ABCD",[Number of articles],"EFGH",[Total sales]),[ABCD]>2),[EFGH])
Hope this helps.
@Ashish_Mathur: That works perfectly! That means, there has to be an intermediate table to filter on, makes sense.
You are welcome.
@Anonymous try this measure
Sum of distinct count =
SUMX ( VALUES ( Table[Brand] ), [Z_DistCount] )
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank you, parry2k, but gives me not the correct result.
I believe you want something like this, should have the right total:
Measure 2 =
VAR __Sales =
SUMMARIZE(articles,[Brand],"__Sales",SUM([Sales]),"__Count",COUNTX(DISTINCT(SUMMARIZE(articles,[Articles])),[Articles]))
RETURN
SUMX(FILTER(__Sales,[__Count]>2),[__Sales])
See attached, Page 2, articles table.
@Greg_Deckler: This is very neat, too. Thank you, Greg. So the part where you state
COUNTX(DISTINCT(SUMMARIZE(
caters for older version of Power BI, am I right? The younger formula
DISTINCTCOUNT()
makes it shorter than before, correct?
Unless it has changed recently, DISTINCTCOUNT only accepts an actual column in an actual table as a parameter. Thus, if we are working with a table expression, we cannot use DISTINCTCOUNT and have to essentially code around it in the manner shown. There is no DISTINCTCOUNTX function like there is COUNTX so we have to work around that.
@Greg_Deckler : I adapted your formula with DISTINCTCOUNT, and it seemed to work.
Gregs_Measure_adapted =
var _Sales = SUMMARIZE(Table1;Table1[Brand];"_Sales_";SUM(Table1[Sales]); "_Count_"; DISTINCTCOUNT(Table1[Articles]))
Return
SUMX(FILTER(_Sales;[_Count_]>2);[_Sales_])
Do you think, it worked due to the special, simple design of the table?
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
88 | |
78 | |
57 | |
40 | |
39 |
User | Count |
---|---|
117 | |
83 | |
79 | |
48 | |
42 |