Forum Discussion

vjnvinod's avatar
vjnvinod
Impactful Individual
4 years ago
Solved

Dax error

Hi,

 

I have created the below Dax, which is throwing some errors, not sure what I am doing incorrectly

 

Current HCount =
IF (
    SELECTEDVALUE ( WkTbl[Column] ) = TRUE (),
    CALCULATE ( COUNTA ( 'Current HC'[GPN] )MAX ( 'Current HC'[Weeknumber] ) )
)
 

 

  • Hi vjnvinod ,

     

    You canAccording to your formula, for MAX ( 'Current HC'[Weeknumber] ), how exactly do you want to achieve the filtering condition.

    One is to group the Weeknumber fields and find the total value corresponding to each group; the other case is to find the total value corresponding to the maximum Weeknumber.

    M1 =
    VAR max_ =
        MAX ( 'Current HC'[Weeknumber] )
    RETURN
        IF (
            SELECTEDVALUE ( 'Current HC'[column] ) = TRUE (),
            CALCULATE (
                COUNTA ( 'Current HC'[GPN] ),
                FILTER ( ALL ( 'Current HC' ), 'Current HC'[Weeknumber] = max_ )
            )
        )
    M2 =
    IF (
        SELECTEDVALUE ( 'Current HC'[column] ) = TRUE (),
        CALCULATE (
            COUNTA ( 'Current HC'[GPN] ),
            FILTER (
                ALL ( 'Current HC' ),
                'Current HC'[Weeknumber] = MAX ( 'Current HC'[Weeknumber] )
            )
        )
    )


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


    Best Regards,
    Henry


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

4 Replies

  • Filter(table name,SELECTEDVALUE ( WkTbl[Column] ) = TRUE ())

  • Samarth_18's avatar
    Samarth_18
    Community Champion

    Hi vjnvinod ,

     

    Please try this:-

    Current HCount =
    IF (
        SELECTEDVALUE ( WkTbl[Column] ) = TRUE (),
        CALCULATE (
            COUNTA ( 'Current HC'[GPN] ),
            FILTER (
                'Current HC',
                'Current HC'[Weeknumber] = MAX ( 'Current HC'[Weeknumber] )
            )
        )
    )

     

    Thanks,

    Samarth

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Community Support

    Hi vjnvinod ,

     

    You canAccording to your formula, for MAX ( 'Current HC'[Weeknumber] ), how exactly do you want to achieve the filtering condition.

    One is to group the Weeknumber fields and find the total value corresponding to each group; the other case is to find the total value corresponding to the maximum Weeknumber.

    M1 =
    VAR max_ =
        MAX ( 'Current HC'[Weeknumber] )
    RETURN
        IF (
            SELECTEDVALUE ( 'Current HC'[column] ) = TRUE (),
            CALCULATE (
                COUNTA ( 'Current HC'[GPN] ),
                FILTER ( ALL ( 'Current HC' ), 'Current HC'[Weeknumber] = max_ )
            )
        )
    M2 =
    IF (
        SELECTEDVALUE ( 'Current HC'[column] ) = TRUE (),
        CALCULATE (
            COUNTA ( 'Current HC'[GPN] ),
            FILTER (
                ALL ( 'Current HC' ),
                'Current HC'[Weeknumber] = MAX ( 'Current HC'[Weeknumber] )
            )
        )
    )


    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


    Best Regards,
    Henry


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