Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello people!
I have a question regarding using Previous day's closing value as starting point of a calculation to current day's value & repeat the same logic for future days as well.
Date | Inputs | BI | Inbound | Plan Usage | EI | Rank | Previous day value | Previous day closing value |
Wednesday, May 13, 2020 | WC2 - Segs/Foil | 0 | 0 | 48,833 | -48,833 | 105 | 5/12/2020 | -48,833 |
Wednesday, May 13, 2020 | Prime | 0 | 0 | 0 | 0 | 105 | 5/12/2020 0:00 | 0 |
Wednesday, May 13, 2020 | Shred | 0 | 0 | 60,102 | -60,102 | 105 | 5/12/2020 0:00 | -60,102 |
Wednesday, May 13, 2020 | RSI | 0 | 0 | 48,833 | -48,833 | 105 | 5/12/2020 0:00 | -48,833 |
Wednesday, May 13, 2020 | WC1 - PS/MLC | 0 | 0 | 52,589 | -52,589 | 105 | 5/12/2020 0:00 | -52,589 |
Wednesday, May 13, 2020 | WC3 - 1x/5x/6x | 0 | 0 | 63,858 | -63,858 | 105 | 5/12/2020 0:00 | -63,858 |
Wednesday, May 13, 2020 | RAR | 0 | 0 | 93,909 | -93,909 | 105 | 5/12/2020 0:00 | -93,909 |
Wednesday, May 13, 2020 | Hardeners | 0 | 0 | 7,513 | -7,513 | 105 | 5/12/2020 0:00 | -7,513 |
Thursday, May 14, 2020 | Shred | 167,225 | 210,000 | 47,581 | 329,644 | 113 | 5/13/2020 0:00 | -60,102 |
Thursday, May 14, 2020 | RSI | 2,252,565 | 126,000 | 38,659 | 2,339,906 | 113 | 5/13/2020 0:00 | -48,833 |
Thursday, May 14, 2020 | Prime | 576,535 | 0 | 0 | 576,535 | 113 | 5/13/2020 0:00 | 0 |
Thursday, May 14, 2020 | WC1 - PS/MLC | 103,455 | 42,000 | 41,633 | 103,822 | 113 | 5/13/2020 0:00 | -52,589 |
Thursday, May 14, 2020 | WC2 - Segs/Foil | 77,880 | 84,000 | 38,659 | 123,221 | 113 | 5/13/2020 0:00 | -48,833 |
Thursday, May 14, 2020 | WC3 - 1x/5x/6x | 128,665 | 210,000 | 50,554 | 288,111 | 113 | 5/13/2020 0:00 | -63,858 |
Thursday, May 14, 2020 | RAR | -632,261 | 0 | 74,345 | -706,606 | 113 | 5/13/2020 0:00 | -93,909 |
Thursday, May 14, 2020 | Hardeners | 49,205 | 0 | 5,948 | 43,257 | 113 | 5/13/2020 0:00 | -7,513 |
Friday, May 15, 2020 | RSI | 0 | 168,000 | 48,833 | 119,167 | 121 | 5/14/2020 0:00 | 2,339,906 |
Friday, May 15, 2020 | Prime | 0 | 0 | 0 | 0 | 121 | 5/14/2020 0:00 | 576,535 |
Friday, May 15, 2020 | RAR | 0 | 0 | 93,909 | -93,909 | 121 | 5/14/2020 0:00 | -706,606 |
Friday, May 15, 2020 | Hardeners | 0 | 0 | 7,513 | -7,513 | 121 | 5/14/2020 0:00 | 43,257 |
Friday, May 15, 2020 | Shred | 0 | 252,000 | 60,102 | 191,898 | 121 | 5/14/2020 0:00 | 329,644 |
Friday, May 15, 2020 | WC1 - PS/MLC | 0 | 42,000 | 52,589 | -10,589 | 121 | 5/14/2020 0:00 | 103,822 |
Friday, May 15, 2020 | WC2 - Segs/Foil | 0 | 84,000 | 48,833 | 35,167 | 121 | 5/14/2020 0:00 | 123,221 |
Friday, May 15, 2020 | WC3 - 1x/5x/6x | 0 | 84,000 | 63,858 | 20,142 | 121 | 5/14/2020 0:00 | 288,111 |
Saturday, May 16, 2020 | WC2 - Segs/Foil | 0 | 0 | 48,833 | -48,833 | 129 | 5/15/2020 0:00 | 35,167 |
Saturday, May 16, 2020 | WC3 - 1x/5x/6x | 0 | 0 | 63,858 | -63,858 | 129 | 5/15/2020 0:00 | 20,142 |
Saturday, May 16, 2020 | Prime | 0 | 0 | 0 | 0 | 129 | 5/15/2020 0:00 | 0 |
Saturday, May 16, 2020 | Shred | 0 | 0 | 60,102 | -60,102 | 129 | 5/15/2020 0:00 | 191,898 |
Saturday, May 16, 2020 | WC1 - PS/MLC | 0 | 0 | 52,589 | -52,589 | 129 | 5/15/2020 0:00 | -10,589 |
Saturday, May 16, 2020 | RAR | 0 | 0 | 93,909 | -93,909 | 129 | 5/15/2020 0:00 | -93,909 |
Saturday, May 16, 2020 | Hardeners | 0 | 0 | 7,513 | -7,513 | 129 | 5/15/2020 0:00 | -7,513 |
Saturday, May 16, 2020 | RSI | 0 | 84,000 | 48,833 | 35,167 | 129 | 5/15/2020 0:00 | 119,167 |
I tried using the Rank & previous day methd, but think i'm missing something simple.
BI is usually populated for only one day
EI = BI + Inbound - Usage
this is the BI for next day & the calculations continues into the future
is this something that could be replicated?
Solved! Go to Solution.
Hi @lokeswer ,
We can use the following measure to meet your requirement.
EI =
VAR min_date =
CALCULATE ( MIN ( 'Table'[Date] ), ALLSELECTED () )
VAR min_date_value =
CALCULATE (
MIN ( 'Table'[Inputs] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] = min_date )
)
RETURN
min_date_value
+ CALCULATE (
SUM ( 'Table'[Inbound] ),
FILTER ( ALL ( 'Table'[Date] ), 'Table'[Date] <= MAX ( 'Table'[Date] ) )
)
- CALCULATE (
SUM ( 'Table'[Usage] ),
FILTER ( ALL ( 'Table'[Date] ), 'Table'[Date] <= MAX ( 'Table'[Date] ) )
)
And the result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @lokeswer ,
We can use the following measure to meet your requirement.
EI =
VAR min_date =
CALCULATE ( MIN ( 'Table'[Date] ), ALLSELECTED () )
VAR min_date_value =
CALCULATE (
MIN ( 'Table'[Inputs] ),
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Date] = min_date )
)
RETURN
min_date_value
+ CALCULATE (
SUM ( 'Table'[Inbound] ),
FILTER ( ALL ( 'Table'[Date] ), 'Table'[Date] <= MAX ( 'Table'[Date] ) )
)
- CALCULATE (
SUM ( 'Table'[Usage] ),
FILTER ( ALL ( 'Table'[Date] ), 'Table'[Date] <= MAX ( 'Table'[Date] ) )
)
And the result like this,
If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?
BTW, pbix as attached.
Best regards,
Community Support Team _ zhenbw
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@v-zhenbw-msft Thanks for the help.
I think this works. Atleast got me to the final solution. I had to create a seperate measure that does the math & then create a calculate column filtering for earlier date, mathing input to get the result.
thanks again
@lokeswer - I'm with @AllisonKennedy not exactly certain of what I am looking at and your desired outcome. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
But maybe see my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...
@AllisonKennedy , @Greg_Deckler , @parry2k Thanks for chiming in.
Date | Inputs | BI | Inbound | Usage | EI |
5/1/2020 | A | 10 | 1 | 2 | 9 |
5/1/2020 | B | 10 | 2 | 4 | 8 |
5/1/2020 | C | 10 | 3 | 6 | 7 |
5/2/2020 | A | 9 | 1 | 2 | 8 |
5/2/2020 | B | 8 | 2 | 4 | 6 |
5/2/2020 | C | 7 | 3 | 6 | 4 |
5/3/2020 | A | 8 | 1 | 2 | 7 |
5/3/2020 | B | 6 | 2 | 4 | 4 |
5/3/2020 | C | 4 | 3 | 6 | 1 |
5/4/2020 | A | 7 | 1 | 2 | 6 |
5/4/2020 | B | 4 | 2 | 4 | 2 |
5/4/2020 | C | 1 | 3 | 6 | -2 |
This table is what i'm trying to get to,
Steps:
5/1/2020 = BI is already given by inputs , so EI = BI + inbound - Planned usage
5/2/2020 = BI is the EI of 5/1/2020(Previous day) matching corresponding inputs, hence the EI = BI +inbound - Planned usage
5/3/2020 = BI is the EI of 5/2/2020(Previous day) matching corresponding inputs, hence the EI = BI +inbound - Planned usage
5/4/2020 = BI is the EI of 5/3/2020(Previous day) matching corresponding inputs, hence the EI = BI +inbound - Planned usage
The dates & the inputs are both important. this is where i'm getting in circles with recursive
I would like to carry this formula for future dates as well!
Sorry I'm not sure I fully understand what you're trying to do. Is the table you posted the desired result or what you've been trying? What is the desired result?
Are you wanting a cumulative measure adding previous day to current and continuing on? If so, you will need a DimDate table and DAX time intelligence (either DATESYTD or DATESBETWEEN)
https://allisonkennedycv.blogspot.com/2020/04/dimdate-what-why-and-how.html
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@lokeswer you need to run cumulative total for your columns and then get previous day value. There are many posts on how to create cumulative/running total in Power BI, here is link to one or you can use quick measures for running total.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |