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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Create Custom Column with multiple IF functions

Hi,

 

I have a table 'PlanYear' that I need to add a new column to.  I need this column to return "Current" if the [PlanYear] column is equal to 2021.  I also need this column to return "Prior" if the [PlanYear] column minus 1 is 2020 and return "Historical" if [PlanYear] is anythng else.

 

I tried to create the column as follows but it didn't work.  I know I am close but was hoping to get some help.

 

New Column = IF ( YEAR ( TODAY () ) = 'PlanYear'[PlanYear], "Current", IF ( YEAR ( TODAY () ) = 'PlanYear'[PlanYear] - 1, "Prior", "Historical" ) )
 
Here is a photo of the table:
Capture3.PNG
 
1 ACCEPTED SOLUTION
smpa01
Community Champion
Community Champion

@Anonymous  change it to

if (year(today())-1=[planyear],"prior"
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

3 REPLIES 3
smpa01
Community Champion
Community Champion

@Anonymousplease change the formatting of Plan Year column to Integer, it is currently formatted as text

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
Anonymous
Not applicable

While that fixed the #ERROR...my 2020 row is returning "Historical" instead of "Prior".  How should I go about resolving that?

 

Capture4.PNG

smpa01
Community Champion
Community Champion

@Anonymous  change it to

if (year(today())-1=[planyear],"prior"
Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.