Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello, I am looking for how to calculate the monthly difference as well as the delta or percentage of monthly increase or decrease, in terms of an inventory of items, in excel I have to place the formula manually, I consider that power bi can do it only by selecting the months to compare.
I appreciate a lot for yo
Solved! Go to Solution.
Here is a good paragraph on this issue I found on the web:
https://www.reddit.com/r/PowerBI/comments/9m0b49/dax_refer_to_previous_row_of_same_column/
Alternatively, and arguably a better approach, you may use Power Query before your data hits the DAX engine. Power Query bypasses the issue with DAX (discussed in the next two paragraphs) in multiple ways - the most elegant (although advanced - there's simpler methods) would List.Accumulate().
However, and every other post missed this, the answer to "Is it possible to have a Calculated DAX column that uses the previous rows calculated value as an input? " is NO. This is a recursive question. DAX cannot do recursion.
The reason why is simple: when the engine is compiling your calculated columns the smallest atomic unit in the DAX engine is a column - not a cell, like Excel. DAX cannot calculate the first cell in a column, then the next, then the next etc because it has no concept of a cell. It calculates the entire column at once because there is nothing smaller. This is a very important concept to understand when first learning DAX.
Help when you know. Ask when you don't!
think about unpivoting your data to look more like this
Categoria | Mes | cantidad | differencia * mes | delta |
Desktops | Enero | 10 | ||
Desktops | Febrero | 4 | -6 | 40.00% |
Desktops | Marzo | 15 | 11 | 375.00% |
Desktops | Abril | 9 | -6 | 60.00% |
Laptops | Enero | 30 | 21 | 333.33% |
Laptops | Febrero | 12 | -18 | 40.00% |
Laptops | Marzo | 15 | 3 | 125.00% |
Laptops | Abril | 45 | 30 | 300.00% |
the calculations that involve comparison with the "preceding row" are much easier to do in excel than in power bi. You can do them there but it involves writing a lot of dax code. Do the calculation before you load the data and user power bi to create your reports
Help when you know. Ask when you don't!
Thank you Kentyler for your guidance.
Regards
Here is a good paragraph on this issue I found on the web:
https://www.reddit.com/r/PowerBI/comments/9m0b49/dax_refer_to_previous_row_of_same_column/
Alternatively, and arguably a better approach, you may use Power Query before your data hits the DAX engine. Power Query bypasses the issue with DAX (discussed in the next two paragraphs) in multiple ways - the most elegant (although advanced - there's simpler methods) would List.Accumulate().
However, and every other post missed this, the answer to "Is it possible to have a Calculated DAX column that uses the previous rows calculated value as an input? " is NO. This is a recursive question. DAX cannot do recursion.
The reason why is simple: when the engine is compiling your calculated columns the smallest atomic unit in the DAX engine is a column - not a cell, like Excel. DAX cannot calculate the first cell in a column, then the next, then the next etc because it has no concept of a cell. It calculates the entire column at once because there is nothing smaller. This is a very important concept to understand when first learning DAX.
Help when you know. Ask when you don't!
Really helpfull information, I´ll taka as solution to use power Query, too advanced for me but ill try it. 🙂
Regards