Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Need to get Uniqie IDs count by group of Pause/No Pause. If ID has any 1 "Pause", then should be counted in only Pause category even though it has entry for "No Pause"
ID | Pauses |
W5021 | No Pause |
W5021 | Pause |
W5021 | Pause |
W3111 | No Pause |
W3111 | No Pause |
W2011 | Pause |
Result | ||
Pauses | Id's Count | Reason |
Pause | 2 | W2011 and W5021 (has one Pause , so should be exluded from No Pause) |
No Pause | 1 | W3111 has No Pause only |
Solved! Go to Solution.
Give this a try.
ID's Corrected =
VAR _Pause = CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Pauses] = "Pause" )
VAR _NoPause = EXCEPT ( CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Pauses] = "No Pause" ), _Pause )
VAR _PauseNoPause = CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Pauses] IN {"Pause", "No Pause"} )
VAR _Missing = EXCEPT ( CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Pauses] = "Missing" ), _PauseNoPause )
VAR _Type = SELECTEDVALUE ( YourTable[Pauses] )
RETURN
SWITCH (
TRUE (),
_Type = "Pause", COUNTROWS ( _Pause ),
_Type = "No Pause", COUNTROWS ( _NoPause ),
_Type = "Missing", COUNTROWS ( _Missing )
)
Give this a try.
ID's Corrected =
VAR _Pause = CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Pauses] = "Pause" )
VAR _NoPause = EXCEPT ( CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Pauses] = "No Pause" ), _Pause )
VAR _PauseNoPause = CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Pauses] IN {"Pause", "No Pause"} )
VAR _Missing = EXCEPT ( CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Pauses] = "Missing" ), _PauseNoPause )
VAR _Type = SELECTEDVALUE ( YourTable[Pauses] )
RETURN
SWITCH (
TRUE (),
_Type = "Pause", COUNTROWS ( _Pause ),
_Type = "No Pause", COUNTROWS ( _NoPause ),
_Type = "Missing", COUNTROWS ( _Missing )
)
What is the logic for counting Missing vs No Pause?
Its based on priority order
1. Pause
2. No Pause
3. Missing
Example
if Id has even single Pause then output will have Pause
if Id has No Pause & Missing then output will have No Pause
if Id has only Missing then output will have Missing
if Id has Pause & Missing then output will have Pause
if Id has Pause , No Pause & Missing then output will have Pause
I believe this will do what you are looking for. My test gives me the result you want at least.
ID's Corrected =
VAR _Pause = CALCULATETABLE ( DISTINCT ( YourTable[ID] ), YourTable[Pauses] = "Pause" )
VAR _NoPause = EXCEPT ( DISTINCT ( YourTable[ID] ), _Pause )
VAR _Type = SELECTEDVALUE ( YourTable[Pauses] )
RETURN
SWITCH (
TRUE (),
_Type = "Pause", DISTINCTCOUNT ( YourTable[ID] ),
_Type = "No Pause", COUNTROWS ( _NoPause )
)
Hi, Thank you for the response, solution in great. However if there is addition value in Pauses column
column "Missing" then how to count that in measure?
ID Pauses
W5021 No Pause
W5021 Pause
W5021 Pause
W3111 No Pause
W3111 Missing
W2011 Pause
W1111 Missing
Output as :
Pauses Id
Pause 2
No Pause 1
Missing 1
User | Count |
---|---|
93 | |
85 | |
78 | |
68 | |
62 |
User | Count |
---|---|
113 | |
99 | |
96 | |
64 | |
58 |