Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
DrHematite
Frequent Visitor

Graphing data over disparate dates

Hi everyone,

 

I have a dataset with a table structured as follows:

 

DatePart NumberAccumulated QtyChange
1/03/2020A150
4/03/2020B220
5/03/2020A16+1
6/03/2020B21-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.

1 ACCEPTED SOLUTION

@DrHematite I think you want this output 

 

blank dates.gif

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.

View solution in original post

3 REPLIES 3
v-easonf-msft
Community Support
Community 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.

 

test pbix file

 

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.

amitchandak
Super User
Super User

@DrHematite 

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 

 

blank dates.gif

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.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.