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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

If statement to not change value if FALSE

Hello,

 

I am creating a column to update/relace values if the condition is TRUE. If the condition is FALSE, I dont want to change the existing value. 

For example:

Innitially:
TestVAL = 1

GOAL:
TestVAL = IF(WEEKDAY(TODAY()) = "Monday", TestVal+1(Which Returns 2), (ELSE, Keep the whatever the old value was, in this case 1)

So essentially, this changes the value of TestVAL by 1 on each monday. If its not monday, the value should remain as it is. 

Any help is appriciated. 

 

Thank you in advanced.

 

Best Regards,

Maitri

1 ACCEPTED SOLUTION

Hi @Anonymous 

 

The code you are using is in DAX while DAX doesn't allow you to replace some part in an existing column. You can use this code to create a new column and give the new column a different name from TestVAL. For example,

vjingzhang_0-1653465764635.png

 

If you want to transform an existing column without adding a new column, you need to do this with Power Query instead of DAX. Let us know what your expected result should be like based on some sample data, then we can suggest more accordingly. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

3 REPLIES 3
Vijay_A_Verma
Super User
Super User

Use the below DAX formula

 

= IF(WEEKDAY(TODAY())=2, TestVAL+1, TestVAL)

 

In PQ, you can use following

 

= if Date.DayOfWeek(DateTime.FixedLocalNow())=1 then TestVAL+1 else TestVAL

 

Anonymous
Not applicable

The entire formula whould be:

 

TestVAL = IF(WEEKDAY(TODAY())=2, TestVAL+1, TestVAL)

 

And Dax is not allowing me to make a circular reference. The Last parameter(TestVAL) is greyed out and is not recognized. 

Is it possible to make TestVal a function column and write a function for this? If so, can you help with the function?

Thaknks for your reply. 

Hi @Anonymous 

 

The code you are using is in DAX while DAX doesn't allow you to replace some part in an existing column. You can use this code to create a new column and give the new column a different name from TestVAL. For example,

vjingzhang_0-1653465764635.png

 

If you want to transform an existing column without adding a new column, you need to do this with Power Query instead of DAX. Let us know what your expected result should be like based on some sample data, then we can suggest more accordingly. 

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors