Forum Discussion
Calculated column - Need some advanced editor advice
Greatest community,
I need to create a calculated column in my fact table. The ambition is to take the old column with values [Value] and restate to new prices, depending on which [Channel] and [Year] it is.
I want to write a new calculated column as [Value - Restated]
For example:
[Year] = 2022 should not be restated (because these values are correct, always!).
In this case [Value - Restated] = [Value].
But if year is 2021....
And [Channel] = A, should be [Value - Restated] = [Value] * 1.05
or [Channel] = B, should be [Value - Restated] = [Value] * 0.9
.... and so on, and so on for a few channels.
Who is able to support in writing the script for such calculated column?
Anonymous , Create a new column like
Switch(True(),
[Year] = 2022 ,[Value] ,
[Year] = 2021 && [Channel] = A, [Value] * 1.05,
[Year] = 2021 && [Channel] = B, [Value] * 0.9,// add others
[Value] //default
)
2 Replies
- amitchandakSuper User
Anonymous , Create a new column like
Switch(True(),
[Year] = 2022 ,[Value] ,
[Year] = 2021 && [Channel] = A, [Value] * 1.05,
[Year] = 2021 && [Channel] = B, [Value] * 0.9,// add others
[Value] //default
)
- AnonymousNot applicable
Thank you Amit! This is working quite well.
Question: What is the reason we put [Value] at the end of the query?
Does it mean that it is the default value if the criteria are not met?