Forum Discussion
ahhollan
5 years agoHelper I
Simple if(format syntax question
I have a column with values of Non-Covid and Covid. If the value is Covid, the fiscal year needs to be formatted and populated based on the Scheduled Start column. If the value is Non-Covid, the fisc...
- 5 years ago
If this is a calculated column in a table, try:
Fiscal Month/Yr = IF( '2700 WO Listing'[Covid vs Non-Covid (groups)]="Non-Covid", FORMAT('2700 WO Listing'[Reported Date],"MMM-yyyy"), FORMAT('2700 WO Listing'[Scheduled Start],"MMM-yyyy") )If you are using this in a measure, try:
Fiscal Month/Yr = IF( MAX( '2700 WO Listing'[Covid vs Non-Covid (groups)]) = "Non-Covid", FORMAT('2700 WO Listing'[Reported Date],"MMM-yyyy"), FORMAT('2700 WO Listing'[Scheduled Start],"MMM-yyyy") )
DataZoe
5 years agoMicrosoft Employee
ahhollan this syntax should work for calculated column:
Fiscal Month/Yr =
IF (
'2700 WO Listing'[Covid vs Non-Covid (groups)] = "Non-Covid",
FORMAT ( '2700 WO Listing'[Reported Date], "MMM-yyyy" ),
FORMAT ( '2700 WO Listing'[Scheduled Start], "MMM-yyyy" )
)
IF (
'2700 WO Listing'[Covid vs Non-Covid (groups)] = "Non-Covid",
FORMAT ( '2700 WO Listing'[Reported Date], "MMM-yyyy" ),
FORMAT ( '2700 WO Listing'[Scheduled Start], "MMM-yyyy" )
)
but it would not work for a measure.
also, the way you have it written will make it a text column. You could also remove the format() from each part and just return each them as dates, then format the column into the desired format if you want it to still behave as a date column.