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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sirros_iot
Helper IV
Helper IV

Time in a certain period, figuring out if is day or night

Hello all

 

I'm trying to find out if one data was sent to me in the night or in the day. 

 

OBS: I think that I can't use calculated columns, the data is coming from a device(arduino) and I'm getting the data from the Power BI online dashbord. 

 

This is what I'm trying to do:

 

               Here I transform the timestamp into time:

               .UTCTime =
                          VAR UnixDays = [.ts] / (60*60*24)

                          RETURN
                          ((DATEVALUE("1/1/1970") + UnixDays))

 

               And here I'm working with that time:

               .Night =
               VAR X = IF( TIME(06;00;00) <= [.UTCTime] && [.UTCTime] < TIME(20;00;00)
               ; 1 ; 0)


              RETURN

              X

 

If I drop the [.UTCTime] in the table I get an error I think because of being a measure.

All my [.Night] column is returning only 0 or 1. What should I do? Any idea   

 

Captura de Tela (6).pngThanks

4 REPLIES 4
v-yuezhe-msft
Employee
Employee

@sirros_iot,

The max valid date in Power BI is 9999/12/31, thus when you use (DATEVALUE("1/1/1970") + UnixDays) to calculate UTCTime, the max value of UnixDays is 2932896.

I am not sure the value of your [.ts] measure, but if its value exceeds 2932896 * 60 * 60 *24, you will get error when drop the [.UTCTime] measure to table.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello @v-yuezhe-msft

 

I have this measure working but only if I select a row.

Do you think I can put it in the column?

 

Captura de Tela (7).png

@sirros_iot,

Could you please share the PBIX file to me? You can send the PBIX file via Private Message.

The issue is caused by that the value of [.ts] measure exceeds 2932896 * (60*60*24), but not related to that measure or column you put the formula in .

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
sirros_iot
Helper IV
Helper IV

Any idea, I don't know even if it is possible kk, thanks

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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