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
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
v-eqin-msft
Community Support
Community Support

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
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.