Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
ahhollan
Helper I
Helper 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 fiscal year needs to be formatted and populated based on the Reported Date column.  My formula is 

Fiscal Month/Yr = if('2700 WO Listing'[Covid vs Non-Covid (groups)]="Non-Covid"(FORMAT('2700 WO Listing'[Reported Date],"MMM-yyyy",'2700 WO Listing'[Scheduled Start],"MMM-yyyy)))
 
What is wrong with my syntax?
1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@ahhollan 

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")
                     )

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

3 REPLIES 3
DataZoe
Microsoft Employee
Microsoft 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" )
)

 

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.

Respectfully,
Zoe Douglas (DataZoe)



Follow me on LinkedIn at https://www.linkedin.com/in/zoedouglas-data
See my reports and blog at https://www.datazoepowerbi.com/

lkalawski
Resident Rockstar
Resident Rockstar

@ahhollan 

you lost some parentheses, formulas and quotation marks. Try this:

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" )
)

 



 

PBI_SuperUser_Rank@1x.png

Proud to be a Super User.

If I helped, please accept the solution

and give kudos

 

PaulDBrown
Community Champion
Community Champion

@ahhollan 

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")
                     )

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.