The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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
Solved! Go to Solution.
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.
Proud to be a 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,
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.
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.
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.
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,
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.
Proud to be a Super User! | |
User | Count |
---|---|
69 | |
64 | |
62 | |
55 | |
28 |
User | Count |
---|---|
184 | |
82 | |
65 | |
48 | |
38 |