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
DYY94
Helper I
Helper I

Subtract a date with number

Hello Comuunity, 

 

I want to do this calculation  : 

- For exemple: 

  • [Maturite] - [MR/365] : 24/11/2025 - 3

Capture 6.PNG

 

 

 

Expected Output : 

Capture 7.PNG

 

 

 

So i have created new table called Maturite Modifier in order to do this calculation but i had one issue, it give me always number  '1' for all colmun instead the real numbers from [MR/365]. 

 

[MR/365]:

 MR.PNG

Knowing that [MR/365] It's measure.

 

- This is the Output i have for now : 

Capture 8.PNG

 

Here a simplified pbix file to understand the issue. 


https://drive.google.com/file/d/1Y2eAmjcVyWDJozOTxEaNFXh3F9ZeNpmu/view?usp=sharing

 

Thanks. 

10 REPLIES 10
v-cgao-msft
Community Support
Community Support

Hi @DYY94 ,

 

Please try this:

Measure = 
VAR _date = MAX('Output'[Maturite])
VAR _result = DATE(YEAR(_date)+[MR/365],MONTH(_date),DAY(_date))
RETURN
_result

vcgaomsft_0-1672048391872.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Hi @v-cgao-msft ,

 

Thanks for your reply ! 

 

Your code works fine but not the Output i wanted. 

I want to give the range of dates like this:

24/11/2025 - 3 : 

24/11/2025 => 24/11/2022

24/11/2025 => 24/11/2023

24/11/2025 => 24/11/2023

 

Capture 7.PNG

 

 

Thanks. 

Mahesh0016
Super User
Super User

Mahesh0016_0-1670928551101.png

 

Mahesh0016
Super User
Super User

Subtract a date = CALCULATE(MAX('Date'[Date]),DATEADD('Date'[Date],-2,YEAR))

Hello @DYY94 ,
I hope above formula helpful for you ...... if it is useful for you kindly accept as solution mark .
 
thank you!

Hi @Mahesh0016 , 

 

Thanks for your help. 

 

I just used your code. it's not the output i wanted. it gave me always the same date or it should gave me the other dates. 

 

This is the output with your code : 

Capture 9.PNG

Expected output : 

 

Capture 7.PNG

 

 

 

Thanks. 

you should Use same date column in max and Dateadd function.

 

yes I just did that but it didn't work either. 

- If you want you can test it with the simple file i shared. 

https://drive.google.com/file/d/1Y2eAmjcVyWDJozOTxEaNFXh3F9ZeNpmu/view?usp=sharing

 

Capture 10.PNG

Please share only PBI file cant find out your pbi file so.....

 

@Mahesh0016 , 

 

I'm not allowed to share Pbix file directly here. that's why i shared via this link. 

just click on it and download it. 

 

https://drive.google.com/file/d/1Y2eAmjcVyWDJozOTxEaNFXh3F9ZeNpmu/view?usp=sharing

date interval "-2" replase with your column [MR/365].

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.