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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
wiktorkramerato
Regular Visitor

How to get latest value for each day where I also have a time stamp besides the date.

Hi everyone,

Tried googling my issue, but every case is somehow different or I'm too bad at this.
I have a couple of servers, with their own disks and how much space they have.
A lot of Servers with many partitions and many timestamps.
I would like to have only the latest free space% value from each single day.

ServerAndDisk                              Device                                  InstanceName            HrDate+Time 24h         Free space %

ServerBerlinC: ServerBerlinC:02/07/2024 06:0088
ServerBerlinC: ServerBerlinC:02/07/2024 19:0089
ServerTokyoD: ServerTokyoC:02/07/2024 10:0071
ServerHoustonD: ServerHoustonF:05/07/2024 15:00

14

ServerBerlinE: ServerBerlinE:01/07/2024 16:00

90

ServerBerlinC: ServerBerlinC:01/07/2024 14:3060



I want to get results like these:

ServerBerlinC:ServerBerlinC:02/07/2024 19:0089
ServerTokyoD:ServerTokyoC:02/07/2024 10:0071
ServerHoustonD:ServerHoustonF:05/07/2024 15:00

14

ServerBerlinE:ServerBerlinE:01/07/2024 16:00

90

ServerBerlinC:ServerBerlinC:01/07/2024 14:3060


I tried grouping by, but somehow I get many duplicates.
Much appreciate any tips. Thank you.

1 ACCEPTED SOLUTION
dufoq3
Super User
Super User

Hi @wiktorkramerato,

 

Result

dufoq3_0-1720452793025.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk4tKkstckotysnMc7ZS0kERAHLBYgZG+gbm+kYGRiYKBmZWBgZAIQsLpVgd0rUbWkK1WyJpD8nPrsx3QegG87FpNoBoNjdE0uyRX1pckp+HpB0qAuS7gQ0wRRhgCjHA0ATD8a5YHA8WMzBEaIf63dKABL8jaTexMgZpNwNqjwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ServerAndDisk = _t, Device = _t, InstanceName = _t, #"HrDate+Time 24h" = _t, #"Free space %" = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"HrDate+Time 24h", type datetime}, {"Free space %", type number}}, "de-DE"),
    Ad_DateHelper = Table.AddColumn(ChangedType, "DateHelper", each DateTime.Date([#"HrDate+Time 24h"]), type date),
    GroupedRows = Table.Group(Ad_DateHelper, {"Device", "InstanceName", "DateHelper"}, {{"All", each Table.MaxN(_, {"HrDate+Time 24h"}, 1) , type table}}),
    CombinedAll = Table.Combine(GroupedRows[All]),
    #"Removed Columns" = Table.RemoveColumns(CombinedAll,{"DateHelper"})
in
    #"Removed Columns"

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

View solution in original post

2 REPLIES 2
dufoq3
Super User
Super User

Hi @wiktorkramerato,

 

Result

dufoq3_0-1720452793025.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCk4tKkstckotysnMc7ZS0kERAHLBYgZG+gbm+kYGRiYKBmZWBgZAIQsLpVgd0rUbWkK1WyJpD8nPrsx3QegG87FpNoBoNjdE0uyRX1pckp+HpB0qAuS7gQ0wRRhgCjHA0ATD8a5YHA8WMzBEaIf63dKABL8jaTexMgZpNwNqjwUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ServerAndDisk = _t, Device = _t, InstanceName = _t, #"HrDate+Time 24h" = _t, #"Free space %" = _t]),
    ChangedType = Table.TransformColumnTypes(Source,{{"HrDate+Time 24h", type datetime}, {"Free space %", type number}}, "de-DE"),
    Ad_DateHelper = Table.AddColumn(ChangedType, "DateHelper", each DateTime.Date([#"HrDate+Time 24h"]), type date),
    GroupedRows = Table.Group(Ad_DateHelper, {"Device", "InstanceName", "DateHelper"}, {{"All", each Table.MaxN(_, {"HrDate+Time 24h"}, 1) , type table}}),
    CombinedAll = Table.Combine(GroupedRows[All]),
    #"Removed Columns" = Table.RemoveColumns(CombinedAll,{"DateHelper"})
in
    #"Removed Columns"

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

foodd
Super User
Super User

Hello @wiktorkramerato , and thank you for sharing your question with the Community.  Please remember to adhere to the decorum of the Community Forum when asking a question.

Please provide your work-in-progress Power BI Desktop file (with sensitive information removed) that covers your issue or question completely in a usable format (not as a screenshot).  You can upload the PBIX file to a cloud storage service such as OneDrive, Google Drive, Dropbox, or to a Github repository, and then share the file’s URL.

https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

This allows members of the Forum to assess the state of the model, report layer, relationships, and any DAX applied.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors