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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
PaulaL
Frequent Visitor

increase date column based on conditions

Hi All, I am having some issues with how to approach my query so any help would be greatly appreciated.

 

I have a date column that I need to increase based on two other columns values.

 

e.g. Date Reported column - 17/12/2018

 

If my Impact Column = "Urgent" and my Department = "Stores" I would need to increase my Date Reported Column to 18/12/2018

 

However if my Impact Column = "Standard" and my Department = "Floor" I would need to increase my Date Reported Column to 20/12/208

 

I would ideally like to not touch the original Date Reported Column but move this new value to another column.

 

So Far I have created a custom column and this is my code however it doesnt work.

 

AmendedDateReported = if(And(SurveyCorrectiveAction[Impact] = "Urgent", SurveyCorrectiveAction[LookUp] = "Stores"), Date.AddDays([DateReported],1),Blank ())

 

Thanks

Paula

1 ACCEPTED SOLUTION
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@PaulaL,

If you create  a custom column in Power BI Desktop query editor, please use formula below.

if [Impact] = "Urgent" and [LookUp] = "Stores" then Date.AddDays([DateReported],1) else if
[Impact] = "Standard" and [LookUp] = "Floor" then Date.AddDays([DateReported],3) else null

1.PNG

If you create a calcualted column, please using DAX below.

Column = if (and(SurveyCorrectiveAction[Impact] = "Urgent", SurveyCorrectiveAction[LookUp] = "Stores") ,SurveyCorrectiveAction[DateReported]+1 ,if(and(SurveyCorrectiveAction[Impact] = "Standard" , SurveyCorrectiveAction[LookUp] = "Floor" ), SurveyCorrectiveAction[DateReported]+3,BLANK()))

Capture.PNG

Regards,

Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@PaulaL,

If you create  a custom column in Power BI Desktop query editor, please use formula below.

if [Impact] = "Urgent" and [LookUp] = "Stores" then Date.AddDays([DateReported],1) else if
[Impact] = "Standard" and [LookUp] = "Floor" then Date.AddDays([DateReported],3) else null

1.PNG

If you create a calcualted column, please using DAX below.

Column = if (and(SurveyCorrectiveAction[Impact] = "Urgent", SurveyCorrectiveAction[LookUp] = "Stores") ,SurveyCorrectiveAction[DateReported]+1 ,if(and(SurveyCorrectiveAction[Impact] = "Standard" , SurveyCorrectiveAction[LookUp] = "Floor" ), SurveyCorrectiveAction[DateReported]+3,BLANK()))

Capture.PNG

Regards,

Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yuezhe-msftThank you very much for this, will it also work if I need to add multiple other impacts and departments? if I expand the else if?

@PaulaL,

It should work. If you get any issues using above formula, you can post back with sample data and expected result.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

Check out the November 2024 Power BI update to learn about new features.