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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Setosa
Advocate I
Advocate I

Return with If statement in dax

I am trying to get the AMT3 if the measure is divisible by 13 get Amt1, otherwise i would like to get the current week value Amt2. but the code below produce a blank outcome. is there a way to fix the code below ? many thanks in advance.

Amt3 =

VAR Amt1 =
CALCULATE(
    [measure],
    FILTER('Calendar', MOD( 'Calendar'[Fiscal Week num],13 ) = 0 ))

VAR Amt2=
CALCULATE(
    [measure],
    FILTER('Calendar', 'Calendar'[get_current_week] = TRUE() ) )


Return
IF( MOD(MAX( 'Calendar'[Fiscal Week num]),13 ) = 0 , Amt1,  Amt2 )

where get_current_week is a calculated column
get_current_week = WEEKNUM([Date],2) = WEEKNUM(TODAY(),2)
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Setosa ,

Please update the formula of measure as below and check if it can return the expected result.

Amt3 =
VAR Amt1 =
    CALCULATE (
        [measure],
        FILTER ( 'Calendar', MOD ( 'Calendar'[Fiscal Week num], 13 ) = 0 ),
        ALL ( 'yourfacttable' )
    )
VAR Amt2 =
    CALCULATE (
        [measure],
        FILTER ( 'Calendar', 'Calendar'[get_current_week] = TRUE () ),
        ALL ( 'yourfacttable' )
    )
RETURN
    IF ( MOD ( MAX ( 'Calendar'[Fiscal Week num] ), 13 ) = 0, Amt1, Amt2 )

 

If the above one can't help you figure out, please provide some raw data in your table (exclude sensitive data) with Text format, the formula of [measure] and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @Setosa ,

Please update the formula of measure as below and check if it can return the expected result.

Amt3 =
VAR Amt1 =
    CALCULATE (
        [measure],
        FILTER ( 'Calendar', MOD ( 'Calendar'[Fiscal Week num], 13 ) = 0 ),
        ALL ( 'yourfacttable' )
    )
VAR Amt2 =
    CALCULATE (
        [measure],
        FILTER ( 'Calendar', 'Calendar'[get_current_week] = TRUE () ),
        ALL ( 'yourfacttable' )
    )
RETURN
    IF ( MOD ( MAX ( 'Calendar'[Fiscal Week num] ), 13 ) = 0, Amt1, Amt2 )

 

If the above one can't help you figure out, please provide some raw data in your table (exclude sensitive data) with Text format, the formula of [measure] and your expected result with backend logic and special examples. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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