The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I'm looking for a DAX calculation which does DISTINCTCOUNT with a certain condition. If a Customer has two different Priorities, it should only do a count on the lowest Priority. To demonstrate with dummy data:
Customer Priority
Jan | 5 |
Jan | 1 |
Tom | 2 |
Dirk | 6 |
You see that Customer Jan has two rows, one with Priority 5 and 1. In this case I want to DISTINCTCOUNT the Customer only for the lowest Priority, being 1 in this case. The end result should look as follows.
Thanks in advance!
Solved! Go to Solution.
Hi @FVZ
Thank you very much FreemanZ and dharmendars007 for your prompt reply.
Try this:
Create measures.
Lowest Priority =
CALCULATE(
MIN('Table'[Priority]),
ALLEXCEPT('Table', 'Table'[Customer])
)
Distinct Customer Count =
CALCULATE(
DISTINCTCOUNT('Table'[Customer]),
FILTER(
'Table',
'Table'[Priority] = 'Table'[Lowest Priority]
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @FVZ
Thank you very much FreemanZ and dharmendars007 for your prompt reply.
Try this:
Create measures.
Lowest Priority =
CALCULATE(
MIN('Table'[Priority]),
ALLEXCEPT('Table', 'Table'[Customer])
)
Distinct Customer Count =
CALCULATE(
DISTINCTCOUNT('Table'[Customer]),
FILTER(
'Table',
'Table'[Priority] = 'Table'[Lowest Priority]
)
)
Here is the result.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
hi @FVZ ,
try like:
measure =
VAR _table =
ADDCOLUMNS(
VALUES(data[Customer]),
"LowestPriority",
CALCULATE(MIN(data[Priority])
)
VAR _result =
CALCULATE(
DISTINCTCOUNT(data[Customer]),
TREATAS(
_table,
data[Customer],
data[Priority]
)
)
RETURN _result
It works to a certain extend, but only as a total. If I put the Priority column on the axis, I still see it counting double. Any advice/adjustments on the code? Would appreciate it!
Hello @FVZ ,
Please try the below measure to count customers for lowest priority.
Lowest Priority Customer Count =
COUNTROWS(
SUMMARIZE('YourTable','YourTable'[Customer],"LowestPriority",
MIN('YourTable'[Priority]))
If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!
Thank You
Dharmendar S
It works to a certain extend, but only as a total. If I put the Priority column on the axis, I still see it counting double. Any advice/adjustments on the code? Would appreciate it!
User | Count |
---|---|
25 | |
10 | |
8 | |
6 | |
5 |
User | Count |
---|---|
31 | |
11 | |
10 | |
10 | |
9 |