Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
Hello everyone,
I have a column that contains Transaction Times.
How do I create a calculated column that differentiates the time into different categories like below.
If Time is within 23:45:01.0000000 to 06:45:00.0000000, then it's Night.
If Time is within 06:45:01.0000000 to 15:15:00.0000000 then it's Morning.
If Time is within 15:15:01.0000000 to 23:45:00.0000000 then it's Noon.
Thanks!
Solved! Go to Solution.
Hi @Anonymous - create a below calculated column , replace your table name and time column
Proud to be a Super User! | |
You can create a calculated column that uses switch statement to specify the period of the day depending on the condition that you specify. See below code.
TimeCategory =
VAR CurrentTime = [TransactionTime]
RETURN
SWITCH(
TRUE(),
CurrentTime >= TIME(23, 45, 1) || CurrentTime < TIME(6, 45, 0), "Night",
CurrentTime >= TIME(6, 45, 1) && CurrentTime < TIME(15, 15, 0), "Morning",
CurrentTime >= TIME(15, 15, 1) && CurrentTime < TIME(23, 45, 0), "Noon",
"Unknown"
)Hope this helps!
Hi @Anonymous - create a below calculated column , replace your table name and time column
Proud to be a Super User! | |
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 67 | |
| 50 | |
| 37 | |
| 27 | |
| 22 |
| User | Count |
|---|---|
| 133 | |
| 119 | |
| 54 | |
| 37 | |
| 31 |