Forum Discussion
Possible Group By required - how?
- Anonymous8 years ago
Okay, so I've resolved it myself.
So to help others, here is what I did...
1) In Power Query, I created a conditional column and assigned 1 to every status value that was not 'validated' or 'validated'.
2) In DAX, I wrote:
tblScriptPacketsCompleted = FILTER(
SUMMARIZE(
refSCRIPT_VALIDATION,
refSCRIPT_VALIDATION[packet_id],
"Values", SUM(refSCRIPT_VALIDATION[ValidatedORValidated_Rejected])
),
[Values] = 0
)3) mScriptPacketsCompleted = COUNT( tblScriptPacketsCompleted[packet_id] )
The measure in Step 3 had the answer I assigned to my card visual. Easy isn't it... when you know how ;-)
Hope this helps others.
Hi Anonymous
Measures below would help.
Measure = IF(MAX([status])="val"||MAX([status])="valid",1,0)
Measure 2 = CALCULATE(COUNT('Table A'[id]),FILTER(ALL('Table B'),[Measure]=0))
Best Regards
Maggie
- Anonymous8 years agoNot applicable
Hi Maggie,
Thanks for your response. It isn't working as I require but this is because I made a small mistake in my example (my fault and now corrected).
I require a count on Table A[id] only when the status of 'val' or 'valid' is the ONLY status in Table B[status] column.
In my example:
a-id 6 has entries of 'val' and 'end'. The Table A[id] should not be counted.
a-id 7 has entries of 'val', 'valid', and 'start'. The Table A[id] should not be counted.
a-id 8 has an entry of 'valid' only. The Table A[id] should be counted.
Thanks.
- Anonymous8 years agoNot applicable
To help explain my requirements more, I have produced the working SQL to acheive what I'm looking for. See below:
SELECT p.id
FROM PACKET AS p
INNER JOIN SCRIPT_VALIDATION sv
ON p.id IN
( SELECT sv.packet_id
FROM SCRIPT_VALIDATION AS sv
GROUP BY sv.packet_id
HAVING SUM(IIF( status <> 'validated' AND status <> 'validated_rejected', 1, 0)) = 0
)
GROUP BY p.id
ORDER BY p.idHow do I acheive the same in DAX?
Thanks.- Anonymous8 years agoNot applicable
Okay, so I've resolved it myself.
So to help others, here is what I did...
1) In Power Query, I created a conditional column and assigned 1 to every status value that was not 'validated' or 'validated'.
2) In DAX, I wrote:
tblScriptPacketsCompleted = FILTER(
SUMMARIZE(
refSCRIPT_VALIDATION,
refSCRIPT_VALIDATION[packet_id],
"Values", SUM(refSCRIPT_VALIDATION[ValidatedORValidated_Rejected])
),
[Values] = 0
)3) mScriptPacketsCompleted = COUNT( tblScriptPacketsCompleted[packet_id] )
The measure in Step 3 had the answer I assigned to my card visual. Easy isn't it... when you know how ;-)
Hope this helps others.