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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Return a column for seconds starting from 07:00am

I want to return the seconds starting the count from 07:00am without restarting the count after every 60 seconds

 

So the results should look like this

 

Reda89_0-1652708420664.png

 

 

 

 

1 ACCEPTED SOLUTION
rocky09
Solution Sage
Solution Sage

Check this one..
I just used time default time as 7:50:10 to test the Dax code. You can change it to 7:00:00

_Counter = 
var _defaultime = TIME(7,50,10)

return

IF('Table'[Time] >_defaultime,

DATEDIFF(_defaultime,'Table'[Time],SECOND),
BLANK()
)

rocky09_0-1652714436054.png

 

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Anonymous ,

 

Since there are multiple conditions based on time  07:00:00(>, < , =), and you used DATEDIFF() twice with the same experssion, you could use a variable and SWITCH() to simplify the syntax:

_Counter = 
VAR _defaultime = TIME (7, 00, 00 )
VAR _diff = DATEDIFF ( _defaultime, muchData_MultipleBelts[Time], SECOND )

RETURN SWITCH (TRUE (),[Time] > _defaultime, _diff,[Time] < _defaultime,( 60 * 60 * 24 ) + _diff,BLANK ())

Output:

Eyelyn9_0-1652928667130.png

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

rocky09
Solution Sage
Solution Sage

Check this one..
I just used time default time as 7:50:10 to test the Dax code. You can change it to 7:00:00

_Counter = 
var _defaultime = TIME(7,50,10)

return

IF('Table'[Time] >_defaultime,

DATEDIFF(_defaultime,'Table'[Time],SECOND),
BLANK()
)

rocky09_0-1652714436054.png

 

Anonymous
Not applicable

I changed your dax code so at 00:00:00 the count of seconds continue untill 7:00:00

 

 

 

_Counter = 
var _defaultime = TIME(7,00,00)

return

IF(muchData_MultipleBelts[Time] >_defaultime,

DATEDIFF(_defaultime,muchData_MultipleBelts[Time],SECOND),

IF(muchData_MultipleBelts[Time] < _defaultime,

(60*60*24) + DATEDIFF(_defaultime, muchData_MultipleBelts[Time], SECOND),
BLANK()
))

 

 

 

Can you check if its correct? I mean it works but maybe there is a better way 

Hi, Looks good.

SpartaBI
Community Champion
Community Champion

@Anonymous create this calculated column and make it a whole number / decimal number date type:

Column 2 = ('Table'[Column] - 1/86400 * 60 * 60 * 7.5) * 86400

In your example it looks like you meant 07:30:00 so I wrote 7.5
In case it's than replace it with 7.5 with 7


2022-05-09 22_36_04-Power BI Workspace Datasets License Permissions - Microsoft Power BI Community.png

Showcase Report – Contoso By SpartaBI


SpartaBI_3-1652115470761.png  SpartaBI_1-1652115142093.png   SpartaBI_2-1652115154505.png

Full-Logo11.png

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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