Forum Discussion
Group BY related doubt
- 8 years ago
Try this MEASURE
Centuries = VAR temp = FILTER ( SUMMARIZE ( 'deliveries', 'deliveries'[match_id], deliveries[batsman], "runs", SUM ( deliveries[batsman_runs] ) ), [runs] >= 100 ) RETURN COUNTROWS ( temp )
Thanks for your suggestion. I tried with below calculation. summarize functionality works fine but somehow filter is not being applied in complete calculation & hence I am getting incorrect result. I tried below formula but then it gives me number of matches batsman played irrespective of score >=100
Centuries = var temp=SUMMARIZE('deliveries','deliveries'[match_id],deliveries[batsman],"total_runs",SUM(deliveries[batsman_runs]))
return
CALCULATE(COUNTROWS(temp),FILTER(temp,[total_runs]>=100))
Also one additional scenario, I have another summary table which stores match level details & has relationship with deliveries table using ID=MatchID.
If I use your formula CALCULATE(COUNT([match_id]),FILTER(temp,[total_runs]>=100)) result remains same even if I select other sesson. But using CALCULATE(COUNTROWS(temp),FILTER(temp,[total_runs]>=100)) it at least changes (Though incorrectly as described above :-))
I can solve many more scenario once I get answer to this query. Awaiting your response. Thanks.
Dear Zubair_Muhammad and v-qiuyu-msft, Could you please help with your expertise?
- Zubair_Muhammad8 years ago
Community Champion
Try this MEASURE
Centuries = VAR temp = FILTER ( SUMMARIZE ( 'deliveries', 'deliveries'[match_id], deliveries[batsman], "runs", SUM ( deliveries[batsman_runs] ) ), [runs] >= 100 ) RETURN COUNTROWS ( temp )- ajinkya19078 years ago
Helper II
Zubair_Muhammad - You are Awesome !!!
The solution worked absolutely fine. Thank you very much. This method will help me in many other calculations.
Thanks to v-qiuyu-msft for your suggestion. It helped too :-)
- Zubair_Muhammad8 years ago
Community Champion
- ajinkya19078 years ago
Helper II
Zubair_Muhammad I have one doubt, What if I need to calculate max runs scored by any batsman using similar calculation? In other words, How to use specific column of temp table. e.g [runs] in this case. applying Max[runs] should solve the problem right?
Please note -
1) I know the answer is achievable by some other DAX formula (other than summarize or group by) but I am curious about modiying given formula, It will help me to calculate few other scenarios
2) With above formula if I simply sum the runs, It may add 2 centuries as well (If any player scores century in 2 matches, It will sum that up & show as max value)
- ajinkya19078 years ago
Helper II
Dear Zubair_Muhammad, Did you get chance to go through this query?