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 folks,
Please, I have a table like this
Category1 | Client |
A | 1 |
B | 1 |
B | 2 |
A | 3 |
A | 4 |
B | 4 |
Distinct Count of Client
4
Distinct Count of Client only if Category1 has different values
2 (because Client 1 ans 4 has A and B values)
Using DAX, how can I achieve this??
Let me reintroduce the question...also include a new dimension here to better explains the context
Category1 | Date | Client |
A | 01/01/2020 | 1 |
B | 02/01/2020 | 1 |
B | 01/01/2020 | 2 |
A | 02/01/2020 | 3 |
A | 01/01/2020 | 4 |
B | 01/01/2020 | 4 |
The distinct count has to change if the dimensions are filtered, like
Case 1) Distinct count of Client = 4
Case 2) Distinct count of Client in 01/01/2020 = 3
Case 3) Distinct count of Client that has both A and B category = 2
Case 4) Distinct count of Client in 01/01/2020 that has both A and B category = 1
I need to measure the distinct count if Category1 has no filter, if the Client has A and B or if the Client has A OR B value...
Can it be done in one measure?? Using diferent dimensions?
Sorry my english, it is not thaaat good.
Pravin,
The function
values=Sumx(Summerize(table,table[Client],"Count",DistinctCount(table[Category1])),if([Count]>1,1,0))
is returning 2 if the "Client" has "A" and "B" values at the same time.
But this is not the total number of distinct Clients...is 4
Category1 | Date | Client |
A | 01/01/2020 | 1 |
B | 02/01/2020 | 1 |
B | 01/01/2020 | 2 |
A | 02/01/2020 | 3 |
A | 01/01/2020 | 4 |
B | 01/01/2020 | 4 |
The distinct count has to change if the dimensions are filtered, like
Case 1) Distinct count of Client = 4
Case 2) Distinct count of Client in 01/01/2020 = 3
Case 3) Distinct count of Client that has both A and B category = 2
Case 4) Distinct count of Client in 01/01/2020 that has both A and B category = 1
I need to measure the distinct count if Category1 has no filter, if the Client has A and B or if the Client has A OR B value...
Can it be done in one measure?? Using diferent dimensions?
Just reading your replies, are you wanting a measure that behaves differently depending on whether certain filters are applied? That is certainly possible using functions like ISFILTERED.
Do you want a measure that:
Both my and @Anonymous 's measures posted earlier return option 2.
Could you clarify in which cases you want option 1 & option 2?
Regards,
Owen
Hi @felipevaz
Distinct Count of Client=DistinctCount(table[Client])
Distinct Count of Client only if Category1 has different values=Sumx(Summerize(table,table[Client],"Count",DistinctCount(table[Category1])),if([Count]>1,1,0))
Drag above measures in seperate card visuals.
Thanks & regards,
Pravin Wattamwar
www.linkedin.com/in/pravin-p-wattamwar
If I resolve your problem Mark it as a solution and give kudos.
Hi @felipevaz
Something like this should do what you want:
Distinct Count of Client only if Category1 has different values =
COUNTROWS (
FILTER (
VALUES ( YourTable[Client] ),
CALCULATE ( DISTINCTCOUNT( YourTable[Category1] ) ) > 1
)
)
Regards,
Owen
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 |
---|---|
47 | |
26 | |
19 | |
14 | |
10 |
User | Count |
---|---|
58 | |
50 | |
44 | |
19 | |
19 |