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
Sagarvizz18
Regular Visitor

Changing whole number format to time

Hello, I am working on a project to get the average of the last 4 weeks' revenue on the given day of the week and at a given time. 

For example, Assume today is Friday and  I am checking my revenue at 4 PM (1-hour revenue from 3 PM to 4 PM). I want to compare it to the average of the last 4 Friday's data at 4 PM. 

I have writtwen a DAX formula, 

Ave last hour2 = AVERAGEX(

                FILTER(vertica_output,

                 vertica_output[Day of Week] =  WEEKDAY(TODAY(),2)   &&
                 vertica_output[time] =  HOUR(NOW()),

                CALCULATE(SUM(vertica_output[actual_impressions]))
               
                )

Everything is working fine except for the highlighted text in red. Here, vertica_output[time] is in time format ( column for every hour ex. 3PM, 4PM, etc..) now this hour(now()) ggivesme value in whole number format ( 1,2, 19,20, etc). So I am not getting desired output. 

Can anyone please help me to change the RHS part to time format?

Thank you,

Attaching table for better understanding!!

image.png

1 ACCEPTED SOLUTION

hey @FreemanZ, Thanks for the suggestion. However, it did not work because RHS is in text format and LHS is in the time format. Although, I could figure out the solution. 
vertica_output[time] =  
TIME(HOUR(now())-1,0,0))
I used the time time function here to convert hour(now())-1 in to the time function from whole number.

 

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @Sagarvizz18 

try like:

vertica_output[time] =  FORMAT(NOW(), "h:mm:ss")

hey @FreemanZ, Thanks for the suggestion. However, it did not work because RHS is in text format and LHS is in the time format. Although, I could figure out the solution. 
vertica_output[time] =  
TIME(HOUR(now())-1,0,0))
I used the time time function here to convert hour(now())-1 in to the time function from whole number.

 

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.