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

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.

Reply
iDataDrew
Advocate IV
Advocate IV

Multiple snapshot times; convert Date/Time to Date and only keep the latest snapshot values

I have tables that consist of projects with their associated costs.  The problem I'm running into is that sometimes multiple snapshots are taken on the same day, resulting in multiple rows for the same project on the same day.  See sample image below.  You can view sample data here

 

MultipleDateTime.png

 

Here's the problem I'm running into.  I want to visualize the Cost field with a line chart.  If I keep the HistoryDate field as Date/Time, then there's a data-point for each Date/Time value (so multiple data-points for the same day).  The shape of the line is fine, but I want each data-point to represent a single day.  If I convert the field to a data type of Date then the values for each snapshot time within the same day get summed (e.g. 9,744 + 9,744 + 9,744 = 29,232 instead of just 9,744).  This results in large spikes on days where multiple snapshots have been taken.

 

I would prefer to do something in the Query Editor that makes it where it only keeps the latest snapshot time for each day per project and deletes the earlier snapshots.  This sounds like it would require a lot of M code though and I'm not advanced in this area.  Is this possible?  Or is there another solution using DAX?  I've already asked my manager if something could be done on the DB side of things, but it appears this won't be possible.  Thanks for your help.

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@iDataDrew,

 

You may follow the following steps.

1) Add a custom column [Date] and change type to Date

=[HistoryDate]

2) Sort [HistoryDate] in descending order

3) Hold the Ctrl key to select [Project Num] and [Date], then Remove Rows > Remove Duplicates

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-chuncz-msft
Community Support
Community Support

@iDataDrew,

 

You may follow the following steps.

1) Add a custom column [Date] and change type to Date

=[HistoryDate]

2) Sort [HistoryDate] in descending order

3) Hold the Ctrl key to select [Project Num] and [Date], then Remove Rows > Remove Duplicates

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-chuncz-msft do you know how I might write a measure that references the MIN() time (Date/Time) for each day?

@v-chuncz-msft, thanks for the reply.  This works...partially.  It keeps the earlier snapshot time and removes the latest one, no matter how I sort it.  This may suffice though.  I think most of the rows are the same, so it doesn't matter which one gets removed.  If there are differences in the rows, I don't think they're major, and the latest removed duplicate would just show up in the next snapshot time for the next day.  So I don't think anything is really being lost.

@iDataDrew,

 

See solutions in links below that use Power Query and DAX. For any new question, please post a new message.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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