Forum Discussion
Power Bi GroupBy count and Having
- 6 years ago
Hey vipul03 ,
with a slight variation of the "the measure" the IDs will just be counted:
the measure just counting the ids = SUMX( ADDCOLUMNS( SUMMARIZE( FILTER( 'Table2' , 'Table2'[Active] = 1 ) , Table2[ID] ) , "dc" , [Distinct Count field 2] ) , var _dc = [dc] return IF(_dc > 1 , 1 , BLANK()) )Then it's possible to create something like this:
Regards,
Tom
Hi kentyler, here is the sample :
| ID | Active | field 2 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
| 1 | 1 | 1 |
| 2 | 1 | 1 |
| 1 | 1 | 2 |
| 3 | 1 | 1 |
| 4 | 0 | 1 |
| 3 | 1 | 0 |
| 5 | 1 | 1 |
| 6 | 0 | 0 |
Active is boolean. Field 2 is also boolean. We need to get distinct cout of ids where field 2 value count is more than 1
- TomMartens6 years agoSuper User
Hey,
first I created this measure:Distinct Count field 2 = DISTINCTCOUNT('Table2'[field 2])then I created this measure, the final measure:
the measure = SUMX( ADDCOLUMNS( SUMMARIZE( FILTER( 'Table2' , 'Table2'[Active] = 1 ) , Table2[ID] ) , "dc" , [Distinct Count field 2] ) , var _dc = [dc] return IF(_dc > 1 , _dc , BLANK()) )This allows to create a table visual like so:
Wondering if this provides the expected result.
Regards,
Tom
- smpa016 years agoCommunity Champion
vipul03 do you mean this
Count := CALCULATE(COUNT('Table 1'[ID])) DistinctCountMeasure:= IF([Count]>1, CALCULATE(DISTINCTCOUNT('Table 1'[ID]),VALUES('Table 1'[ID])),0)- vipul036 years agoFrequent Visitor
Hi smpa01
basically, I need to get dictinct count of ID where Active is 1 and field2 value count is greater than 1
so for the given sample :
result must count :
ID1, will be counted , as active =1 and field 2 has three values 0 ,1 and 2
ID 2, wil not be counted as field 2 has only one value
ID 3 will be counted as actuive =1 and field two has two values 0 and 1
IDs 4 ,5 and 6 won't be counted as they have just one value for field 2
- TomMartens6 years agoSuper User
Hey vipul03 ,
with a slight variation of the "the measure" the IDs will just be counted:
the measure just counting the ids = SUMX( ADDCOLUMNS( SUMMARIZE( FILTER( 'Table2' , 'Table2'[Active] = 1 ) , Table2[ID] ) , "dc" , [Distinct Count field 2] ) , var _dc = [dc] return IF(_dc > 1 , 1 , BLANK()) )Then it's possible to create something like this:
Regards,
Tom