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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Conditional Column

Hello,

 

Checking to see if I can create a condtional column that applies to a certain date. For instance I need a column to only apply to 2021 but not 2020. 

 

So I would create a column that says If x = y than 1 otherwise 0. I need this to apply only to 2021 data but not for 2020. Could i create something that leaves 2020 Null?

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Picture1.png

 

New Column CC =
IF (
'Table'[Year] = 2021,
SWITCH ( TRUE (), 'Table'[x] = 'Table'[y], 1, 0 ),
BLANK ()
)

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Picture1.png

 

New Column CC =
IF (
'Table'[Year] = 2021,
SWITCH ( TRUE (), 'Table'[x] = 'Table'[y], 1, 0 ),
BLANK ()
)

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

mahoneypat
Microsoft Employee
Microsoft Employee

You could do a custom column with a function like this

 

= if [Year] = 2021 then 1 else null

 

or, if it's a Date column

 

= if Date.Year([Date]) = 2021 then 1 else null

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.