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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
PatriceGREN
Regular Visitor

Using Dateadd

Hi, 

I can t use the DATEADD function correctly.

DATEADD(HISTORIQUE[DateFinPeriodeEssai1],-nbjprevenance,DAY)

-nbjprevenance = variable 

if I put 0 in place of the variable, I get the right dates. But as soon as I want to add or subtract, nothing goes, sometimes I have the right answer, sometimes nothing.

Thank you for your help

1 ACCEPTED SOLUTION

Hi,

After many tests, I tried this syntax:

HISTORIQUE[DateFinPeriodeEssai1] - nbjprevenance

and it works.

 

 

View solution in original post

6 REPLIES 6
amitchandak
Super User
Super User

In case you plan to use a slicer, you can have a measure. Here "Add to date" is a slicer

 

Date from slicer = 
Var date1='Add To Date'[Add To Date Value]

return
CALCULATE(maxx(Sales,DATEADD(Sales[Order_Date],date1,DAY)))

 

 

You want to add static value once as column 

 

Date from slicer col = 
Var date1=1

return
DATEADD(Sales[Order_Date],-1*date1,DAY)

Screenshot 2019-09-12 22.09.17.png

 

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

Hi, I understand your solution, but it doesn't work for all my data

parry2k
Super User
Super User

@PatriceGRENcan you provide details on how you are calculating nbjprevenance variable? Also do you have date dimension in your model on which you are performing this DateADD function?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

2019-09-13 09_47_54-Document1 - Microsoft Word.png

Hi,

After many tests, I tried this syntax:

HISTORIQUE[DateFinPeriodeEssai1] - nbjprevenance

and it works.

 

 

Hi, 

datePrevenancePeriodeEssai1 =

var nbj = HISTORIQUE[NombreJourDebutContrataDateJour]

var nbjprevenance =

switch(TRUE(); -- donne le nombre de jours de prévenance à respecter

nbj <8 ; 1;

and(nbj > 8 ; nbj <= 30);2;

and(nbj >30 ; nbj <= 90);15;30 )

return

DATEADD(HISTORIQUE[DateFinPeriodeEssai1];-nbjprevenance;DAY)

 

for the "Date Dimension", I'll look. This is a model that is available to me, I don't know yet everything in it.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors