Forum Discussion
Justas4478
1 year agoPost Prodigy
IF statement calculated column
Hi, I have deliveries table, that are for multiple customers and have PGI and Delivery dates. I created calculated column that counts difference between PGI and Delivery date. Order Day diff...
- 1 year ago
Hi Justas4478 ,
I recommend you to use SWITCH function instead of if statement.
Please try the bellow DAX code:Order Day Adjustment = VAR Customer = 'Store Order data'[Customer] VAR PGIDate = 'Store Order data'[PGI date] VAR OrderDayDiff = 'Store Order data'[Order Day difference] VAR BaseAdjustment = SWITCH( TRUE(), Customer IN {"Stores UK", "Aldi", "Matalan", "Online", "Sandpiper", "TRS"}, -2, Customer = "Stores NI", -3, Customer = "Stores ROI", -5, 0 ) VAR AdditionalAdjustment = SWITCH( TRUE(), WEEKDAY(PGIDate, 2) = 4, -3, // Thursday WEEKDAY(PGIDate, 2) = 5, -2, // Friday 0 ) RETURN OrderDayDiff + BaseAdjustment + AdditionalAdjustment
Anonymous
1 year agoNot applicable
Hi Justas4478 ,
Is your problem solved, if so, you can mark it as correct, if not, provide more detailed information and we can help you better!
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.