Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I have a column "Mode" which has multiple values; A, B, C & D. I need to calculate date difference in days, as per below condition:
If Mode = "A" or "B" , calculate ([Date1] - [Date2]), else
If Mode = "C" or "D" calculate ([Date3] - [Date4])
Please help.
Thanks,
Muralidhar
Solved! Go to Solution.
@murali5431
Add the following as a column,
New Column =
IF ( [Mode] = "A" || [Mode] = "B", DATEDIFF([Date1] , [Date2],DAY), IF( [Mode] = "C" || [Mode] = "D",DATEDIFF([Date3] , [Date4],DAY)))
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@murali5431 , Try like
Switch (true(),
[Mode] in { "A" ,"B"}, datediff([Date1],[Date2],day),
[Mode] in { "C" ,"D"}, datediff([Date3] , [Date4],DAY)
)
@murali5431 , Try like
Switch (true(),
[Mode] in { "A" ,"B"}, datediff([Date1],[Date2],day),
[Mode] in { "C" ,"D"}, datediff([Date3] , [Date4],DAY)
)
@murali5431
Add the following as a column,
New Column =
IF ( [Mode] = "A" || [Mode] = "B", DATEDIFF([Date1] , [Date2],DAY), IF( [Mode] = "C" || [Mode] = "D",DATEDIFF([Date3] , [Date4],DAY)))
________________________
If my answer was helpful, please consider Accept it as the solution to help the other members find it
Click on the Thumbs-Up icon if you like this reply 🙂
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
22 | |
7 | |
6 | |
6 | |
6 |
User | Count |
---|---|
27 | |
10 | |
10 | |
9 | |
6 |