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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Set an IF for different dates

My table follows this structure:

datecolumn1column2
02/01/2020 111222
03/03/2020222777
07/10/2020333555
12/12/2020444999

 

I want to create a new column that, if the date is less than 05/05/2020, then the values will be taken from column1. If the date is greater than 05/05/2020, the value will be taken from column2.

 

The expected result would look like this:

datecolumn1column2new_column
02/01/2020 111222111
12/12/2020222777777
07/10/2020333555555
04/04/2020444999444

 

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

HI @Anonymous ,

 

NEW_COLUMN = IF('Table'[date] < DATE(2020,5,5), 'Table'[column1], 'Table'[column2])


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@camargos88 
@Pragati11 
@amitchandak 
Thanks to everyone for the quick responses! Worked perfectly!

Just a small question before closing the topic: is it possible to insert Hour in this DATE function too? In case I wanted to get values ​​from a specific day and time?

Hi @Anonymous ,

 

There is quite interesting article on how you can use date and time functions in Power BI:

https://medium.com/@kishoripatil1823/date-and-time-dax-functions-in-power-bi-fd9155416178

 

Try checking it out and see how you can implement it in your scenario.

 There is a TIME function in Power BI which you can use. There is an existing thread for this. Check it:

https://community.powerbi.com/t5/Desktop/DAX-IF-statement-based-on-TIME/td-p/889249

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

amitchandak
Super User
Super User

@Anonymous , Try like

 

new column = IF('Table'[date] < DATE(2020,5,5), 'Table'[column1], 'Table'[column2])

new measure = IF(max('Table'[date]) < DATE(2020,5,5), max('Table'[column1]), max('Table'[column2]))

new measure = sumx('Table', IF('Table'[date] < DATE(2020,5,5), 'Table'[column1], 'Table'[column2]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Pragati11
Super User
Super User

HI @Anonymous ,

 

You can create a calculated column as follows:

 

NewValueCol = IF(Tablename[date] < DATE(2020, 05, 05), Tablename[Column 1], Tablename[Column 2])

 

Replace Tablename[date] in above DAX with your table and column.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

camargos88
Community Champion
Community Champion

HI @Anonymous ,

 

NEW_COLUMN = IF('Table'[date] < DATE(2020,5,5), 'Table'[column1], 'Table'[column2])


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors