Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register 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 @mrbuttons07 - 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 @mrbuttons07 - create a below calculated column , replace your table name and time column
Proud to be a Super User! | |
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
90 | |
88 | |
83 | |
64 | |
49 |
User | Count |
---|---|
126 | |
110 | |
87 | |
70 | |
66 |