Forum Discussion

powerbirookiee's avatar
powerbirookiee
Frequent Visitor
3 years ago
Solved

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 ...
  • Anonymous's avatar
    Anonymous
    3 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 Zhou

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.