Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi everyone,
I have a dataset with a table structured as follows:
Date | Part Number | Accumulated Qty | Change |
1/03/2020 | A1 | 5 | 0 |
4/03/2020 | B2 | 2 | 0 |
5/03/2020 | A1 | 6 | +1 |
6/03/2020 | B2 | 1 | -1 |
As you can see, it tracks the changes in inventory of a particular time on each date a transaction occurs.
What I want to be able to do is chart this data, but over all dates. So in the above, we start with part number A1 with 5 pieces on 1/03, and gain another on 5/03. That means our available quantity was 5 on 1/03, 2/03, 3/03 and 4/03 changing to 6 on 5/03. That's what I want to be able to show, but I don't have the dates in between.
Appreciate any help to do this across all the part numbers and for contiguous dates.
Solved! Go to Solution.
@DrHematite I think you want this output
and here is the measure to achieve this, make sure you have a calendar table in your model. There are many blog posts on how to add calendar table, once this table is added, create relationship between the calendar table with your data table and calendar table will be on the one side of the relationship. Would appreciate Kudos 🙂 if my solution helped.
Value =
VAR __startDate = CALCULATE ( MIN ( Running[Date] ), ALLSELECTED( 'Calendar'[Date] ) )
VAR __endDate = CALCULATE ( MAX ( Running[Date] ), ALLSELECTED( 'Calendar'[Date] ) )
VAR __whentoStop = IF ( MAX ( 'Calendar'[Date] ) <= __endDate, 1 )
VAR __lastDate = CALCULATE ( LASTDATE ( Running[Date] ), DATESBETWEEN( 'Calendar'[Date], __startDate, MAX ( 'Calendar'[Date] ) ) )
VAR __value = CALCULATE( MAX ( Running[Accumulated Qty] ), 'Calendar'[Date] = __lastDate ) * DIVIDE( __whentoStop, __whentoStop )
RETURN __value
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.
Hi , @DrHematite
According to my test , @parry2k solution is effective.
If it is ,please mark the his reply as Answered to close this thread.
So that ,other community members will easily find the solution when they get the same issue.
Best Regards,
Community Support Team _ Eason
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
both as new columns
max date = maxx(filter(table, table[Part Number] = earlier(table[Part Number]) && table[Date] < earlier(table[date])),table[date])
diff = maxx(filter(table, table[Part Number] = earlier(table[Part Number]) && table[Date] = earlier(table[max date ])),table[Accumulated Qty])-table[Accumulated Qty]
@DrHematite I think you want this output
and here is the measure to achieve this, make sure you have a calendar table in your model. There are many blog posts on how to add calendar table, once this table is added, create relationship between the calendar table with your data table and calendar table will be on the one side of the relationship. Would appreciate Kudos 🙂 if my solution helped.
Value =
VAR __startDate = CALCULATE ( MIN ( Running[Date] ), ALLSELECTED( 'Calendar'[Date] ) )
VAR __endDate = CALCULATE ( MAX ( Running[Date] ), ALLSELECTED( 'Calendar'[Date] ) )
VAR __whentoStop = IF ( MAX ( 'Calendar'[Date] ) <= __endDate, 1 )
VAR __lastDate = CALCULATE ( LASTDATE ( Running[Date] ), DATESBETWEEN( 'Calendar'[Date], __startDate, MAX ( 'Calendar'[Date] ) ) )
VAR __value = CALCULATE( MAX ( Running[Accumulated Qty] ), 'Calendar'[Date] = __lastDate ) * DIVIDE( __whentoStop, __whentoStop )
RETURN __value
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.
User | Count |
---|---|
125 | |
106 | |
99 | |
63 | |
62 |
User | Count |
---|---|
135 | |
116 | |
101 | |
71 | |
61 |