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
Anonymous
Not applicable

Time Intelligence DAX

I have data like this

 

Time.PNG

 

So whenever my system time match to "IN" time value in the column then I want to show in Status column as "Occupied" and whenever the system time match with "OUT" time value in the column then I want to show in Status column as "Available". So, from 8:00:00 to 17:00:00 I want to show status as "Occupied" and after that onwards I want to show it as "Available". Like this I want to show it for all rows. How to do this.

2 ACCEPTED SOLUTIONS
DataVitalizer
Solution Sage
Solution Sage

Hi @Anonymous 

You can add a calculated column to your table using this code

Status = 
VAR CurrentTime=TIME(HOUR(NOW());MINUTE(NOW());SECOND(NOW()))
Return IF(AND(CurrentTime>='Table'[IN];CurrentTime<'Table'[OUT]);"Occupied";"Available")

Did it work ? 👌Mark it as a solution to help spreading knowledge 👉A kudos would be appreciated

View solution in original post

davehus
Memorable Member
Memorable Member

Hi @Anonymous ,

 

In order for this to be refreshable in a browser, you will need a calculated measure as opposed to a column. Columns are refreshed with the dataset and not dynamically.

Try the code below:

 

Current Time = Time(HOUR(NOW()),MINUTE(NOW()),SECOND(NOW()))
Status = IF(AND([Current Time]>=FIRSTNONBLANK(Test[In],1),[Current Time]<=FIRSTNONBLANK(Test[Out],1)),"Occupied", "Available")

 

This can be refreshed using the refresh button in broswer window or on report load.

 

Ignore the 1 hour current time difference in my example as it's a setting in the service. 

davehus_0-1650545016653.png

 

View solution in original post

6 REPLIES 6
davehus
Memorable Member
Memorable Member

Hi @Anonymous ,

 

In order for this to be refreshable in a browser, you will need a calculated measure as opposed to a column. Columns are refreshed with the dataset and not dynamically.

Try the code below:

 

Current Time = Time(HOUR(NOW()),MINUTE(NOW()),SECOND(NOW()))
Status = IF(AND([Current Time]>=FIRSTNONBLANK(Test[In],1),[Current Time]<=FIRSTNONBLANK(Test[Out],1)),"Occupied", "Available")

 

This can be refreshed using the refresh button in broswer window or on report load.

 

Ignore the 1 hour current time difference in my example as it's a setting in the service. 

davehus_0-1650545016653.png

 

Anonymous
Not applicable

Upto to IN 14:00:00 and OUT 23:00:00 it working fine. But when it coming for IN 15:00:00 and OUT 24:00:00 onwords its not working.

 

Time1.PNG

DataVitalizer
Solution Sage
Solution Sage

Hi @Anonymous 

You can add a calculated column to your table using this code

Status = 
VAR CurrentTime=TIME(HOUR(NOW());MINUTE(NOW());SECOND(NOW()))
Return IF(AND(CurrentTime>='Table'[IN];CurrentTime<'Table'[OUT]);"Occupied";"Available")

Did it work ? 👌Mark it as a solution to help spreading knowledge 👉A kudos would be appreciated

Anonymous
Not applicable

Upto to IN 14:00:00 and OUT 23:00:00 it working fine. But when it coming for IN 15:00:00 and OUT 24:00:00 onwords its not working.

 

Time1.PNG

Hi @Anonymous , That looks like a calculated column to me and not a calculated measure, can you clarify? Columns only updated once at model refresh, they don't update dynamically where as measures have that ability.

 

D

Anonymous
Not applicable

First I tried with calculated measure it was not working with calculated measure so then I tried with calculated column.

 

Time2.PNG

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.