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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Syndicate_Admin
Administrator
Administrator

I need to make two conditionals in DAX language to create a new column

Hi, I have 3 columns and I want to create a fourth one

F G H

TYPE / START DATE / END DATE / NEW COLUMN

Slope / (empty) / (empty) / Slope

X / 10/04/25 / 10/05/25 / 31

Y / 15/04/25 / (empty) / 8

The formula for the NEW COLUMN in excel would be: =IF(F5="Pending";" Pending";SI(H5=""; TODAY()-G5+1; H5-G5+1))

What would it be like in power BI? Thank you in advance

2 ACCEPTED SOLUTIONS
jgeddes
Super User
Super User

Calculated Column =
SWITCH(
TRUE(),
[Type] = "Pending", "Pending",
[End Date] = "", TODAY()-[Start Date] + 1,
[End Date] - [Start Date] + 1
)

Something like this might work for you.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

DataNinja777
Super User
Super User

Hi @Syndicate_Admin ,

 

To create the NEW COLUMN in Power BI using DAX, you can use the SWITCH(TRUE(), ...) pattern to handle multiple conditions in a readable way. This logic will return "Slope" when the TYPE column is "Slope", calculate the number of days from the START DATE to today (plus one) if the END DATE is blank, and otherwise calculate the number of days between the START DATE and END DATE (plus one). Here's the DAX formula you can use:

NEW COLUMN = 
SWITCH(
    TRUE(),
    'YourTable'[TYPE] = "Slope", "Slope",
    ISBLANK('YourTable'[END DATE]), DATEDIFF('YourTable'[START DATE], TODAY(), DAY) + 1,
    DATEDIFF('YourTable'[START DATE], 'YourTable'[END DATE], DAY) + 1
)

Replace 'YourTable' with the actual name of your table if different. This will produce the expected output similar to your Excel formula.

 

Best regards,

View solution in original post

5 REPLIES 5
v-pagayam-msft
Community Support
Community Support

Hi @Syndicate_Admin ,

I wanted to check and see if you had a chance to review our previous response. Please let me know if everything is sorted or if you need any further assistance.

Thank you.

v-pagayam-msft
Community Support
Community Support

Hi @Syndicate_Admin ,
Could you please confirm if the issue has been resolved on your end? If a solution has been found, it would be greatly appreciated if you could share your insights with the community. This would be helpful for other members who may encounter similar issues.
Thank you for your understanding and assistance.

v-pagayam-msft
Community Support
Community Support

Hi @Syndicate_Admin ,
Thank you @DataNinja777  and @jgeddes for the helpful response!
I wanted to check in on your situation regarding the issue. Have you resolved it? If you have, please consider marking the reply that helped you or sharing your solution. It would be greatly appreciated by others in the community who may have the same question.
Thank you.

DataNinja777
Super User
Super User

Hi @Syndicate_Admin ,

 

To create the NEW COLUMN in Power BI using DAX, you can use the SWITCH(TRUE(), ...) pattern to handle multiple conditions in a readable way. This logic will return "Slope" when the TYPE column is "Slope", calculate the number of days from the START DATE to today (plus one) if the END DATE is blank, and otherwise calculate the number of days between the START DATE and END DATE (plus one). Here's the DAX formula you can use:

NEW COLUMN = 
SWITCH(
    TRUE(),
    'YourTable'[TYPE] = "Slope", "Slope",
    ISBLANK('YourTable'[END DATE]), DATEDIFF('YourTable'[START DATE], TODAY(), DAY) + 1,
    DATEDIFF('YourTable'[START DATE], 'YourTable'[END DATE], DAY) + 1
)

Replace 'YourTable' with the actual name of your table if different. This will produce the expected output similar to your Excel formula.

 

Best regards,

jgeddes
Super User
Super User

Calculated Column =
SWITCH(
TRUE(),
[Type] = "Pending", "Pending",
[End Date] = "", TODAY()-[Start Date] + 1,
[End Date] - [Start Date] + 1
)

Something like this might work for you.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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