Forum Discussion

ClemFandango's avatar
ClemFandango
Advocate II
3 years ago
Solved

Dax conditional If statement for counting rows in date table

Hello all, I am trying to use CountRows, but toiling a bit with a conditional if statement. I have the following date table called MMYYDD MMYYDD Count 31/01/2018 3 28/02/2018 3 31/03...
  • lbendlin's avatar
    3 years ago

    here's a general idea of how to implement that

     

    ct2 =
    VAR a =
        SUMMARIZE(
            MMYYDD,
            MMYYDD[MMYYDD],
            "ct",
                VAR d = [MMYYDD]
                RETURN
                    CALCULATE(
                        COUNTROWS( Summary ),
                        COALESCE( Summary[RejoinDate], Summary[MinDate] ) <= d,
                        COALESCE( Summary[DateEnd], Summary[MaxDate] ) > d
                    )
        )
    RETURN
        SUMX( a, [ct] )

     

    You can refine the logic by testing for both conditions together.