Dear experts
I have a case where the calculation before a certain date should be calculated different than after that particular date , here is an example:
I have 2 measures (Discount Ver 3 , Discount Ver 5) , those two measures depends on the Date of purchase , if the Date > 1/12/2020 the discount (if any) should be calculated based on (Discount Ver 5) otherwise the discount calculated based on (Discount Ver 3) .
These are the 2 measures:
Discount Ver 3=
SUMX(
SUMMARIZE( 'order_details', 'Order_details'[OrderNumber],
Order_details[tax_exclusive_discount_amount_order] ),
[tax_exclusive_discount_amount_order]
)
Discount Ver 5=
I need to Use global measures with something like this :
General Measure =
if Date > ‘1/12/2020’ ; [Discount Ver 5] ; [Discount Ver 3 ]
Is this possible?
BrianJ
December 26, 2021, 12:45pm
2
@MAAbdullah47 ,
Yes, totally doable. I would set this up as follows:
General Measure =
SWITCH ( TRUE(),
SELECTEDVALUE( Dates[Date] ) > DATE( 2020, 1, 12), [Discount Ver 5]
SELECTEDVALUE( Dates[Date] ) <= DATE( 2020, 1, 12), [Discount Ver 3],
-9999
)
A few things:
Sorry - I’m on my phone, so can’t properly format the code above
Switch is not necessary here, since it’s only two conditions, but it allows for future expansion to more complex conditions, and is easier to read IMO
Not clear which date format you’re using. If date is Dec 1, you’ll need to flip the month and day in the DATE function.
I hope this is helpful.
1 Like
Thank you so much @BrianJ , I’ll practices the concept and get back to you if I have any notes.
2 Likes
Hello @MAAbdullah47 , a gentle follow up if you were able to check the solution from @BrianJ ?
Please don’t forget if your question has been answered within the forum it is important to mark your thread as ‘solved’.
We request you to kindly take time to answer the Enterprise DNA Forum User Experience Survey ,
We hope you’ll give your insights on how we can further improve the Support forum. Thanks!