Forum Discussion
Subtract a date with number
Hello Comuunity,
I want to do this calculation :
- For exemple:
- [Maturite] - [MR/365] : 24/11/2025 - 3
Expected Output :
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]:
Knowing that [MR/365] It's measure.
- This is the Output i have for now :
Here a simplified pbix file to understand the issue.
https://drive.google.com/file/d/1Y2eAmjcVyWDJozOTxEaNFXh3F9ZeNpmu/view?usp=sharing
Thanks.
10 Replies
- Mahesh0016
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!- Mahesh0016
Super User
date interval "-2" replase with your column [MR/365].
- DYY94
Helper I
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 :
Expected output :
Thanks.
- Mahesh0016
Super User
you should Use same date column in max and Dateadd function.
- Mahesh0016
Super User
- AnonymousNot applicable
Hi DYY94 ,
Please try this:
Measure = VAR _date = MAX('Output'[Maturite]) VAR _result = DATE(YEAR(_date)+[MR/365],MONTH(_date),DAY(_date)) RETURN _resultBest Regards,
Gao
Community Support TeamIf 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
- DYY94
Helper I
Hi Anonymous ,
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
Thanks.