Forum Discussion
rdnguyen
3 years agoHelper V
Count distinct with priority
Hi everyone,
I have a list of items that I did count for late delivery and on time delivery. It means the item could be in both category Late and On-time. By doing the count for each category, I re...
- 3 years ago
Hi rdnguyen ,
Based on your description, I have created a simple sample:
Please try:
Late = var _a = SUMMARIZE('Table',[ID],"Flag",IF("Late" in SELECTCOLUMNS(FILTER(ALL('Table'),[ID]=EARLIER('Table'[ID])),"Category",[Category]),"Late","On-Time")) return COUNTX(FILTER(_a,[Flag]="Late"),[Flag]) On-Time = var _a = SUMMARIZE('Table',[ID],"Flag",IF("Late" in SELECTCOLUMNS(FILTER(ALL('Table'),[ID]=EARLIER('Table'[ID])),"Category",[Category]),"Late","On-Time")) return COUNTX(FILTER(_a,[Flag]="On-Time"),[Flag])Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jianboli-msft
3 years agoCommunity Support
Hi rdnguyen ,
Based on your description, I have created a simple sample:
Please try:
Late =
var _a = SUMMARIZE('Table',[ID],"Flag",IF("Late" in SELECTCOLUMNS(FILTER(ALL('Table'),[ID]=EARLIER('Table'[ID])),"Category",[Category]),"Late","On-Time"))
return COUNTX(FILTER(_a,[Flag]="Late"),[Flag])
On-Time =
var _a = SUMMARIZE('Table',[ID],"Flag",IF("Late" in SELECTCOLUMNS(FILTER(ALL('Table'),[ID]=EARLIER('Table'[ID])),"Category",[Category]),"Late","On-Time"))
return COUNTX(FILTER(_a,[Flag]="On-Time"),[Flag])
Final output:
Best Regards,
Jianbo Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
rdnguyen
3 years agoHelper V
Thanks v-jianboli-msft , work great!