Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi,
I have two columns (one with values, one with dates, see Screenshot marked red). I want to create a calculated column which subtracts each value with the one from the former date (see desired result written in the column on the right hand side).
I know I have to use the earlier-function but I did not get what I wanted so far.
I would be thankful for support!
Solved! Go to Solution.
Hi,
I did as below :
1- Add the Index column to the table in Power Query.
2- Then use below code for create the new column :
Appreciate your Kudos and please mark it as solution if it helps you
Hi,
I did as below :
1- Add the Index column to the table in Power Query.
2- Then use below code for create the new column :
Appreciate your Kudos and please mark it as solution if it helps you
@MahyarTF
Thanks! Yes, that would work if there is a value in each row of the column. Unfortunately there might be some blanks, meaning that if there is no value, it should substract the actual with the last availabe value in the column
Hi @dirkkoch
Please try the below code in the new column I described earlier :
Appreciate your Kudos and please mark it as a solution if it helps you
@MahyarTF Thanks for your support! I managed to do it myself now by creating an adapted Index (with Rankx-Function) leaving out the blank spots. That worked for me!
THe problem with your solution is that it makes the model unnecessarily bloated (as the index column is not really needed). Second, calculated columns are not compressed the way they are when created in Power Query - this results in even more bloat. In big models this may be unacceptable. Therefore, please use Power Query to do such calculations. Unless, of course, you don't care about how big the model is and how fast DAX could be. But I think you should since you pay money for storage. You also want to have fast DAX and columns optimized for access and calculations.
Hi @daXtreme ,
Thanks for your useful advice.
Just learning and trying to improve my knowledge.
This is the solution it was at top of my head but absolutely there are better solutions.
Use Power Query for this because this is where such calculations belong. By the way, the EARLIER function in DAX has been discouraged and you should learn to use variables instead.
Source: https://dax.guide/earlier
Check out the October 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
111 | |
108 | |
108 | |
93 | |
61 |
User | Count |
---|---|
169 | |
138 | |
135 | |
102 | |
86 |