Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
vjnvinod
Impactful Individual
Impactful Individual

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] ) )
)
 
vjnvinod_0-1647349777821.png

 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
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.

View solution in original post

4 REPLIES 4
v-henryk-mstf
Community Support
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.

Samarth_18
Community Champion
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

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

mh2587
Super User
Super User

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


Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



vjnvinod
Impactful Individual
Impactful Individual

@mh2587 

 

see below error, after applying your code

 

vjnvinod_0-1647350389546.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.