Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

COUNTIFS WITH CONDITIONS USING VARIABLES

Hi all,   I'm trying to find the equivalent to a COUNTIFS excel formula in Power BI. I've already looked up related posts and they talk about using the following DAX formulas: CALCULATE, FILTER, SU...
  • MFelix's avatar
    7 years ago

    Hi Anonymous ,

     

    The corresponding IFS on COUNTIFS on dax is made making use of the CALCULATE function alonside with the filters on that function.

     

    You need to create a measure similar to this:

    Countif Aircraft =
    VAR Selected_date =
        MAX ( 'Calendar'[Date] )
    RETURN
        CALCULATE (
            COUNT ( Aircraft[Aircraft] );
            Selected_date >= Aircraft[Start];
            Selected_date <= Aircraft[End]
        )

    Change the table names to your model be aware that in this formula the two tables are not related.

     

    See attach image and PBIX file for explanation:

     

    Regards,

    MFelix