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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply

M formula explanation

Hello community,

 

I'm stucked with M formula:

 

My formula doesn't return what I expected:

 

if [Hours] = {8,8.5,9,9.5,10,10.5,11,11.5} then "morning" else if [Hours] = {18,18.5,19,19.5} then "night" else "none"

 

I have none everywhere

FranckGbadamass_1-1652904249256.png

 

Thank you very much for your help.

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @FranckGbadamass ,

 

Try this:

if [Hours] >= 8 and [Hours] <= 11.5 then "morning"
else if [Hours] >= 18 and [Hours] <= 19.5 then "night"
else "none"

 

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

1 REPLY 1
BA_Pete
Super User
Super User

Hi @FranckGbadamass ,

 

Try this:

if [Hours] >= 8 and [Hours] <= 11.5 then "morning"
else if [Hours] >= 18 and [Hours] <= 19.5 then "night"
else "none"

 

Pete



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

Proud to be a Datanaut!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors