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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
nvbuddy
Regular Visitor

Subtract minimum of a column from each value of a column

So I have a table with two columns: invention and year of its creation. I need a measure, which subtracts the minimum date from each date. If I'd create a new column named Diff, it would be Datediff = [disc_year] - MIN(table[disc_year]). But what if I don't want to create it and have a measure calculating in the same manner instead? Any tips?

1 ACCEPTED SOLUTION
VahidDM
Super User
Super User

Hi @nvbuddy 

Try this:

 Datediff =
Var _Min =calculate(Min(table[disc_year]),all(table))
Var _Mdate = Max(table[disc_year])
Return
_Mdate-_Min


If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!



View solution in original post

2 REPLIES 2
VahidDM
Super User
Super User

Hi @nvbuddy 

Try this:

 Datediff =
Var _Min =calculate(Min(table[disc_year]),all(table))
Var _Mdate = Max(table[disc_year])
Return
_Mdate-_Min


If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!



It works perfectly, thanks! If you don't mind, could you please clarify logic by steps? Why do we use max? And why we should use calculate with MIN, and not only MIN? I've searched for something like an iteration of subtraction for every row, but the logic in DAX differs from pandas in Python or sql (at least in code). Kinda new at Power BI😥

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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