Forum Discussion
Graphing data over disparate dates
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.
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
3 Replies
- amitchandakSuper User
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]
- parry2kSuper User
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
- v-easonf-msftCommunity Support
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.