The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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?
Solved! Go to Solution.
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!!
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😥
User | Count |
---|---|
15 | |
12 | |
8 | |
7 | |
7 |
User | Count |
---|---|
24 | |
20 | |
12 | |
10 | |
7 |