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
Justas4478
1 year agoPost Prodigy
Bibiano_Geraldo Thanks for the response.
It looks to be working at first glance, but I need to check results before accepting as solution.
Bibiano_Geraldo
1 year agoSuper User
Cool, any problem don't hesitate to touch me