Forum Discussion
How to create Calculated column with both Text and Number comparison
- 1 year ago
Hi Kumar_0606
Since you are using several IF the best option is to use a switch statment however your problem saying the it does not allow to compare values it seems to me that one of those columns has the incorrect format, check the format of the Year ccolumn to see if it's a number and try the following measure:
SWITCH( TRUE(), Table[Category]="Plan" && Table[year]>=2020 && Table[Code]= 'USD123', [Measure], Table[Category]="Plan" && Table[year]<2020 && [Code]='USD456', [Measure])
Hi Kumar_0606
Since you are using several IF the best option is to use a switch statment however your problem saying the it does not allow to compare values it seems to me that one of those columns has the incorrect format, check the format of the Year ccolumn to see if it's a number and try the following measure:
SWITCH( TRUE(),
Table[Category]="Plan" && Table[year]>=2020 && Table[Code]= 'USD123', [Measure],
Table[Category]="Plan" && Table[year]<2020 && [Code]='USD456', [Measure])
Thanks Miguel.
I checked the year column, data type is Text so i enclosed year value in quotes in your formula.
- MFelix1 year ago
Super User
Hi Kumar_0606 ,
Glad it worked, but I suggest that you change the year column to a Number format because it will be more efficient.