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!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hallo Everone,
I need help to transform the folowing situation into M query.
I hava the folowing situation, where I need to distinguish my DB in two stagges. where the condition of "Morning" , "Evening" and "night"changes over time.
data that are before 04.02.2018 then if time is between 10:00 and 12:00 then "Morning" and between 12:00 and 18:00 is "Evening" later is "Night" and the data after 04.02.2018 then if time is between 09:00 and 11:00 then "Morning" and between 11:00 and 17:00 is "Evening" later is "Night"
I want to do it directly in the Query so using M language , I am not looking for a measure.
@Anonymous , Try a new column in M-like. As I was not sure on month so, change as per need
if DateTime.Date([Date]) <#date(2018,02,04)
if DateTime.Time([Date]) >= #time(10,0,0) and DateTime.Time([Date]) >= #time(12,0,0) then "Morning" else
if DateTime.Time([Date]) >= #time(12,0,0) and DateTime.Time([Date]) >= #time(18,0,0) then "Evening" else "Night"
else
if DateTime.Time([Date]) >= #time(9,0,0) and DateTime.Time([Date]) >= #time(11,0,0) then "Morning" else
if DateTime.Time([Date]) >= #time(11,0,0) and DateTime.Time([Date]) >= #time(17,0,0) then "Evening" else "Night"
Thank you so much!, I needed to change some <> signs to fit and add then but it worked great 🙂
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!