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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Daniel_76
New Member

Issue with substracting date (date.adddays)

Hello,

 

I have an issue: I have a column (Test) whcih has either a "0" or a "1" in as a check column. Now I want to add a new costum column which should have a corrected date in, I tried now several times but can´t get it working:

 

If I try: 

=if [Test]="1" then Date.AddDays[ar_Date.1]-1 else [ar_Date.1]

it doesn´t substract a day, but just gives me the value as in ar_Date.1 

Tried even the 1 without "", but this just gives an error

 

If I try:

=if [Test]="1" then (Date.AddDays[ar_Date.1],-1) else [ar_Date.1]

I get an "Token RightParen" error at the else

 

If someone could bring me back onto the right path I would be very thankful 🙂
Daniel

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

 

this

 

=if [Test]="1" then (Date.AddDays[ar_Date.1],-1) else [ar_Date.1]

 

 

should be in this way  "(" moved just before [ar_Date.1]

 

=if [Test]="1" then Date.AddDays([ar_Date.1],-1) else [ar_Date.1]

 

 

may be you could get other errors, but try

View solution in original post

3 REPLIES 3
Daniel_76
New Member

Thanks to both of you - had to use both ways to fix it (checked for error with the 2 step approach) and the applied the corrected formula. You made my day 🙂

Anonymous
Not applicable

 

this

 

=if [Test]="1" then (Date.AddDays[ar_Date.1],-1) else [ar_Date.1]

 

 

should be in this way  "(" moved just before [ar_Date.1]

 

=if [Test]="1" then Date.AddDays([ar_Date.1],-1) else [ar_Date.1]

 

 

may be you could get other errors, but try

HotChilli
Super User
Super User

You can debug at your side.

First , add a column like 

if [Test]="1" then "success" else "fail"  .   If you have no errors and you get success and fail values, time to move on.

If not, find out where it's going wrong.

----------

Add another column like

Date.AddDays([ar_Date.1],-1).   Do you get a successful value? If so, move on by combining the above code with this.  If not, find out where it's going wrong.

 

 

Let me know how it goes

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors