Forum Discussion
powerbirookiee
3 years agoFrequent Visitor
DAX Function for Count with filter
Hi everyone, I am new to Power BI and I have no idea in complex DAX functions. I need to create a calculated column or measure (whichever is more appropriate) which counts unique combinations of ...
- Anonymous3 years ago
Hi powerbirookiee ,
Greg_Deckler's measure will only return 1 in subtoatl. Please try this code to create a measure.
Desired Count = VAR __ADD = ADDCOLUMNS ( 'Table', "Count", VAR _COUNTBYID = CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[articleID] ) ) RETURN SWITCH ( TRUE (), [Tag] = "Pink" && _COUNTBYID > 1, BLANK (), 1 ) ) RETURN SUMX ( __ADD, [Count] )Result is as below.
Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
3 years agoNot applicable
Hi powerbirookiee ,
Greg_Deckler's measure will only return 1 in subtoatl. Please try this code to create a measure.
Desired Count =
VAR __ADD =
ADDCOLUMNS (
'Table',
"Count",
VAR _COUNTBYID =
CALCULATE ( COUNTROWS ( 'Table' ), ALLEXCEPT ( 'Table', 'Table'[articleID] ) )
RETURN
SWITCH ( TRUE (), [Tag] = "Pink" && _COUNTBYID > 1, BLANK (), 1 )
)
RETURN
SUMX ( __ADD, [Count] )
Result is as below.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.