Forum Discussion
Count at least one flag
Why though? I need all the conditions in the measure. Then I need to count the distinct olis from each measure. So the entire measure needs to be filtering for those 3 conditions. Ashish_Mathur
If DISTINCTCOUNT is not an option and you have to control very specific sets of filters I think you'd have to go down this sort of route... (away from laptop typing on phone so apologise for any syntax issues).
CountMeasure =
VAR OliSet1 =
CALCULATETABLE (
DISTINCT ( 'Table1'[OLI Number] ),
Condition1,
Condition2
)
VAR OliSet2 =
CALCULATETABLE (
DISTINCT ( 'Table1'[OLI Number] ),
Condition1,
Condition2
)
VAR OliSet3 =
CALCULATETABLE (
DISTINCT ( 'Table1'[OLI Number] ),
Condition1,
Condition2
)
VAR CombinedSet =
DISTINCT (
UNION ( OliSet1, OliSet2, OliSet3 )
)
RETURN COUNTROWS ( CombinedSet )
- poweruser554 years ago
Helper IV
So each oli set will have distinct OLI numbers? Like if the filters produce the same oli number for oli set1 and 2(ex:001)it will only count 001 once in the total? The way I'm reading that is that it's distinct for each conditions. But I want the oli number distinct for each oli set when the total is calculated. bcdobbs
- bcdobbs4 years ago
Community Champion
Can you share a set of test data. As said not by a laptop at moment but can try later.
The code I sent:
1) Builds distinct lists for each set of conditions.
2) Appends them all together (union)
3) Removes duplicates (DISTINCT wrapped round the union).
4) Counts the rows that are left.
- bcdobbs4 years ago
Community Champion
Have been pondering. Think above
works but is inefficient. Would be better to use FILTER with some
or statements. Share some
demo data and conditions that need to be met and will
rewrite.
- poweruser554 years ago
Helper IV
I posted expected result below just in case I wasn't clear. But maybe your solution already solves this just want to make sure. bcdobbs
- poweruser554 years ago
Helper IV
I just tried the union and it ended up giving me my highest number for one of the flags. I guess this means that this one flag was also a Y in the other columns? bcdobbs
- v-kkf-msft4 years ago
Community Support
Hi poweruser55 ,
Has your problem been solved? If it is solved, please mark a reply which is helpful to you.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz