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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
amol0512
Helper I
Helper I

New Column Power Query

Hi, I am trying to create new column to show difference with days between two dates through Power Query but I am not getting expected results. I have 2 columns DOJ(Date of Joining) and DOL(Date of Leaving). If DOJ date column is blank then use Today's date minus DOL else DOJ minus DOL . I tried 2 different ways, 1) with Custom Column 2) Date calculate Age and then edited . They both are giving me same results.

 

= Table.AddColumn(#"Removed Columns", "Custom", each if [DOJ New Joiner] = null then Date.From(DateTime.LocalNow())-[DOL] else [DOJ New Joiner] - [DOL])

 

= Table.AddColumn(#"Added Custom", "Age", each if [DOJ New Joiner] = null then Date.From(DateTime.LocalNow()) - [DOL] else [DOJ New Joiner]-[DOL])  

2 REPLIES 2
v-luwang-msft
Community Support
Community Support

Hi @amol0512 ,

 

Has your problem been solved, if so, please consider Accept a correct reply as the solution or share your own solution to help others find it.

Best Regards
Lucien

amitchandak
Super User
Super User

@amol0512 , seem correct , Try like

Duration.Days(if [DOJ New Joiner] = null then Date.From(DateTime.LocalNow()) - [DOL] else [DOJ New Joiner]-[DOL])

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.