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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Display records by the hour

I am accessing a database with instruments logs at 30 sec interval.

I need to create a visual that display chart not every 30 sec but instead every hour only.

The values doesn't need to be calculated as each reading is the current actual value during the given time.

How can I do this?

 

randomtrader_0-1653997790719.png

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

You could still use this method, just apply visual/page filters where:

time[minutes] = 1 and time[seconds] = 27.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi Pete!

Thank you so much! Indeed it work!

One snappy salute for your help!

watkinnc
Super User
Super User

so there being 120 values per hour, you could add an index column beginning at one, and then a custom column like

 

Table.SelectRows(PriorStepName, each Number.Mod([Index], 120) =0)

 

Actually, this is easier:

 

= Table.Split(TableName, 120){0}[Timestamp]

 

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
Anonymous
Not applicable

I will try this and surely get back to you. Thank you.

BA_Pete
Super User
Super User

Hi @Anonymous ,

 

Paste this into a new blank query in Power Query. It's a time dimension table:

 

let
  hoursTable = Table.FromList({0..23}, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
  renHours = Table.RenameColumns(hoursTable, {{"Column1", "hours"}}),
  minutesTable = Table.FromList({0..59}, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
  secondsTable = Table.FromList({0..59}, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
  addCJminutes = Table.AddColumn(renHours, "minutes", each minutesTable),
  expandCJminutes = Table.ExpandTableColumn(addCJminutes, "minutes", {"Column1"}, {"minutes"}),
  addCJseconds = Table.AddColumn(expandCJminutes, "seconds", each secondsTable),
  expandCJseconds = Table.ExpandTableColumn(addCJseconds, "seconds", {"Column1"}, {"seconds"}),
  addTimeHH = Table.AddColumn(expandCJseconds, "timeHH", each Text.Combine({Text.From([hours], "en-GB"), "00"}, ":")),
  addTimeHHMM = Table.AddColumn(addTimeHH, "timeHHMM", each Text.Combine({Text.From([hours], "en-GB"), Text.From([minutes], "en-GB")}, ":"), type text),
  addTimeHHMMSS = Table.AddColumn(addTimeHHMM, "timeHHMMSS", each Text.Combine({Text.From([hours], "en-GB"), Text.From([minutes], "en-GB"), Text.From([seconds], "en-GB")}, ":"), type text),
  chgAllTypes = Table.TransformColumnTypes(addTimeHHMMSS, {{"timeHH", type time}, {"hours", Int64.Type}, {"minutes", Int64.Type}, {"seconds", Int64.Type}, {"timeHHMM", type time}, {"timeHHMMSS", type time}})
in
  chgAllTypes

 

 

Next, apply this new table to your data model, and relate time[timeHHMMSS] to yourTable[Timestamp].

 

Create measures for each of your values that you want to display using your required aggregation e.g.:

_shipTotal = SUM(yourTable[Ship Total Fuel Cons])

 

Use the time[hours] column and your new measures in your visuals to group measure totals by hours.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Anonymous
Not applicable

Hi Pete,

 

I have followed your advise and relate the time[timeHHMMSS] to my table. However, I may need clarify what we need to achieve. The data logged doesn't need any aggregation as the data read each time is the actual reading by the instruments.

What we'd like to show in our dashboard is the reading on each hour, rather than every 30-second. So that rather than showing 05/24/2022 12:01:27, 05/24/2022 12:01:57 (30 sec interval), it would pick after an hour so that it would be 05/24/2022 01:01:27 which is 1-hour gap. I would really appreciate help on this one as I am really struggling to figure out how to resolve this. Thank you so much and to everyone for their time.

Hi @Anonymous ,

 

You could still use this method, just apply visual/page filters where:

time[minutes] = 1 and time[seconds] = 27.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Power BI Header Change

Power BI Header Update

Read about the exciting updates for the Power BI forum.

Top Solution Authors
Top Kudoed Authors