'How to convert the following tableau calculation into DAX powerbi?

I have a tableau measure which goes like this:

ColumnA= IF [Rating Projection Year 1] = 2021
THEN SUM([Weights Ly]*[Next year rating predicted (1)]*[Inclusion Flag Ly])/SUM([Weights Ly]*[Inclusion Flag Ly])
ELSEIF  [Rating Projection Year 1] = 2022
THEN SUM([Weights Cy]*[Next year rating predicted (1)]*[Inclusion Flag Cy])/SUM([Weights Cy]*[Inclusion Flag Cy])
ELSE 0
END

How can I convert the same in DAX powerbi? Thanks



Solution 1:[1]

Try this(Switch Case):

ColumnA = SWITCH(TRUE(), 
[Rating Projection Year 1] = 2021, SUM([Weights Ly] * [Next year rating predicted (1)]*[Inclusion Flag Ly])/SUM([Weights Ly] * [Inclusion Flag Ly]),
[Rating Projection Year 1] = 2022, SUM([Weights Cy] * [Next year rating predicted (1)]*[Inclusion Flag Cy])/SUM([Weights Cy] * [Inclusion Flag Cy]),
0)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 soniabhishek36