Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello,
I would like to create a grouping for this analysis "What time of the day do customers usually pay their bill?". In my table, I have a transaction date/time column. Now, I would like to group the time by ex. 9AM, 10AM...
Example scenario:
FROM:
Transaction_date_time:
9/1/2020 9:01 AM
9/1/2020 9:30 AM
9/1/2020 9:45 AM
9/1/2020 10:01 AM
9/1/2020 10:11 AM
9/1/2020 10:22 AM
TO:
Transaction_date_time:
9AM
10AM
So i could have a analysis per time of the day and show that in a graph. THank you! 🙂
Solved! Go to Solution.
Hi @icdns
Download example PBIX file with this query.
First convert the transactions date/times into date time type in Power Query, then convert to time type. You can then extract the hour and group by this to get what you want.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstQ31DcyMDJQsLQyMFRw9FWK1UERNDbAImhiiiFoaIBNP1DUECSqgCFsZARWHAsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Transaction_date_time: " = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Transaction_date_time: ", type datetime}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"Transaction_date_time: ", type time}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Time.Hour([#"Transaction_date_time: "])),
#"Grouped Rows" = Table.Group(#"Added Custom", {"Custom"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
#"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Time of Day", each Time.From(#time([Custom],0,0))),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom"})
in
#"Removed Columns"
regards
Phil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.
Proud to be a Super User!
Hi @icdns ,
Based on your description, you can create a column or just modify the original date/time column as follows.
Transaction_time = FORMAT('Sheet4'[Transaction_date_time],"h AM/PM")
Hope that's what you were looking for.
Best Regards,
Yuna
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @icdns ,
Based on your description, you can create a column or just modify the original date/time column as follows.
Transaction_time = FORMAT('Sheet4'[Transaction_date_time],"h AM/PM")
Hope that's what you were looking for.
Best Regards,
Yuna
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hello!
This one worked! However, can i order my axis? Please see image below.
ex. 8AM, 9AM 10AM, 11AM,12PM, 1PM, 2PM 3PM...
Thanks!
Regards,
Inna
Hi @icdns ,
You can do some steps as follows:
1. create a column.
Result:
Hope that's what you were looking for.
Best Regards,
Yuna
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@icdns , You can create a time table and join with that
https://kohera.be/blog/power-bi/how-to-create-a-time-table-in-power-bi-in-a-few-simple-steps/
Separate date and time and join with Date and Time table
date = [Transaction_date_time].date
time =[Transaction_date_time].time
Hi @icdns
Download example PBIX file with this query.
First convert the transactions date/times into date time type in Power Query, then convert to time type. You can then extract the hour and group by this to get what you want.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WstQ31DcyMDJQsLQyMFRw9FWK1UERNDbAImhiiiFoaIBNP1DUECSqgCFsZARWHAsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Transaction_date_time: " = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Transaction_date_time: ", type datetime}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"Transaction_date_time: ", type time}}),
#"Added Custom" = Table.AddColumn(#"Changed Type1", "Custom", each Time.Hour([#"Transaction_date_time: "])),
#"Grouped Rows" = Table.Group(#"Added Custom", {"Custom"}, {{"Count", each Table.RowCount(_), Int64.Type}}),
#"Added Custom1" = Table.AddColumn(#"Grouped Rows", "Time of Day", each Time.From(#time([Custom],0,0))),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom"})
in
#"Removed Columns"
regards
Phil
If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.
Proud to be a Super User!
User | Count |
---|---|
124 | |
108 | |
99 | |
65 | |
62 |
User | Count |
---|---|
137 | |
116 | |
102 | |
71 | |
61 |