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
JMHenriques
Frequent Visitor

get working days since datetime until NOW with decimals

Hi all,

 

I have a Calendar Table with IsWeekend and a table with a "created_at" column in Datetime format.

 

I need to count the days and hours passed since the "created_at" until the refresh date with NOW(). 

 

I can do this with the following measure but the problem is that it's giving me whole numbers although I changed it to Decimal.

_measure_Age = 
COUNTROWS (
    FILTER (
        ALL ( CalendarTable ),
        [Date] >= SELECTEDVALUE (Tickets[created_at])
            && [Date] <= TODAY()
            && [IsWeekend] = "No"
    )
)
 
Is it possible to use decimals in order to get the hours? 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @JMHenriques ,

 

Thanks to @CKN  for the idea.

@JMHenriques Your Tickets table are being filtered because you're using a slicer about “created_at”. When you select a value in the slicer, Tickets table is filtered. If you want to disable this filtering, you can use the Edit Interaction feature.

vmengmlimsft_0-1726024944851.png

 

 

Best regards,

Mengmeng Li

View solution in original post

6 REPLIES 6
CKN
Frequent Visitor

if it's for all weekends (not treating any days such as holidays differently) can you use the figure you already have for hours, divide by 24 for days then by 7 for weeks to get the number of weekends. Round it down and multiply by 48 for hours.

Anonymous
Not applicable

Hi @JMHenriques ,

 

Thanks for @CKN 's reply.

@JMHenriques You'll also need to adjust the number of decimal places if you want the results to be displayed in decimal format.

vmengmlimsft_0-1725958604610.png

 

If you want to calculate the number of hours from the “created_at” of each row to now and the results are displayed as decimals, you can refer to my test.

Measure.

DateDiff = DATEDIFF(MAX('Calendar'[created_at]),UTCNOW(),MINUTE)/60

vmengmlimsft_1-1725958604613.png

 

 

 

 

Best regards,

Mengmeng Li

Thank you @Anonymous, that part worked perfectly for the decimals but I still cannot find a way to make what @CKN suggested of subtracting the weekends... I'am trying to use the COUNTROWS and filter to exclude weekends but no joy for now

Anonymous
Not applicable

Hi @JMHenriques ,

 

Thanks to @CKN  for the idea.

@JMHenriques Your Tickets table are being filtered because you're using a slicer about “created_at”. When you select a value in the slicer, Tickets table is filtered. If you want to disable this filtering, you can use the Edit Interaction feature.

vmengmlimsft_0-1726024944851.png

 

 

Best regards,

Mengmeng Li

CKN
Frequent Visitor

Can you use a DATEDIFF(calculating hours) then subtract COUTROWS of ISWEEKEND days*24?

Sort of... I get it working with the following code:

_measure_Age_Days Weekends = 
DATEDIFF(MAX(Tickets[created_at]),UTCNOW(),hour)/24 - 
COUNTROWS (
    FILTER (
        ALL ( CalendarTable ),
        [Date] >= SELECTEDVALUE (Tickets[created_at])
            && [Date] <= TODAY()
            && [IsWeekend] = "Yes"
    )
)

 

but the measure basically destroys the tables I put it into, making data appear that should have been filtered out by the filters directly in the "page filters". And it also takes like 1 minute to process. Probably in count rows is not the way to go.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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
Top Kudoed Authors