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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ItalianScallion
Frequent Visitor

Night time vs day time

Hello,

I have 2 tables, FactTransaction with column TIME_TPA which is a reading time and the other Sunset_Sunrise_TPA with SUNSET SUNRISE column.
I need a new column that checks weather or not the READINGTIME is at night or during the day.

I tried with an this formula but it shows 4pm as night and 12am as day. 

DayCheck = IF(AND(vw_FactTransaction_Hourly[Time_TPA]>= RELATED(Sunset_Sunrise_TPA[Sunrise]), vw_FactTransaction_Hourly[Time_TPA] <= RELATED(Sunset_Sunrise_TPA[Sunset])),"Daytime","Night")
 
How can I compare these two times so that if TIME_TPA is after SUNSET and before SUNRISE it's nighttime?
Thanks
 
 
EDIT:
Also tried 
DayCheck = IF(AND(TIME(HOUR(vw_FactTransaction_Hourly[Time_TPA]),MINUTE(vw_FactTransaction_Hourly[Time_TPA]),0)>= TIME(HOUR(RELATED(Sunset_Sunrise_TPA[Sunrise])),MINUTE(RELATED(Sunset_Sunrise_TPA[Sunrise])),0), TIME(HOUR(vw_FactTransaction_Hourly[Time_TPA]),MINUTE(vw_FactTransaction_Hourly[Time_TPA]),0) <= TIME(HOUR(RELATED(Sunset_Sunrise_TPA[Sunset])),MINUTE(RELATED(Sunset_Sunrise_TPA[Sunset])),0)),"Daytime","Nighttime")
In an attempt to make it into a time function, no luck, everything but midnight comes out as nighttime lol 
Halp plz
 
1 REPLY 1
Anonymous
Not applicable

Hi @ItalianScallion ,

I have some doubt. Each row in vw_FactTransaction_Hourly[Time_TPA] compare to with each row in Sunset_Sunrise_TPA[Sunset]? If in row 1, there is 05:00:00 in vw_FactTransaction_Hourly[Time_TPA] and 23:00:00 in Sunset_Sunrise_TPA[Sunset], What would it output?  The result is "Night"? Could you please provide more details?

 

How to compare daytime and night?

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Polly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.