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
MXSven
Helper I
Helper I

Transforming a date related Excel formula into DAX

Hi Everybody,

 

I am struggeling with the translation of an Excel formula "StartDate" into Power BI (DAX)

 

StartDate = "="&(Today()-DATE(1970;1;1))*60*60*24,
EndDate = "=1646092800"

 

It appears to me that the "date" & "today" formula concept of excel, which returns an according serial number

doesn't exist in PowerBi

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Ohhhh..

I know, in Power Query , you should use m language, not dax

StartDate = "=" & Text.From(Duration.TotalSeconds(DateTime.From(Date.From(DateTimeZone.SwitchZone(DateTimeZone.LocalNow(), 0))) - #datetime(1970, 1, 1, 0, 0, 0)))

change the 0 to your timezone

DateTimeZone.SwitchZone - PowerQuery M | Microsoft Docs

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

StartDate = (Today()-DATE(1970,1,1))*60*60*24

I put it exactly like this,
but today and date couldn't be recognized

 

MXSven_0-1654851804629.png

 

Anonymous
Not applicable

In Power BI, create a new measure

StartDate = (Today()-DATE(1970,1,1))*60*60*24

 

Thanks for your fast reply

but how do get the measure then into:

MXSven_0-1654853017191.png

 

Anonymous
Not applicable

Ohhhh..

I know, in Power Query , you should use m language, not dax

StartDate = "=" & Text.From(Duration.TotalSeconds(DateTime.From(Date.From(DateTimeZone.SwitchZone(DateTimeZone.LocalNow(), 0))) - #datetime(1970, 1, 1, 0, 0, 0)))

change the 0 to your timezone

DateTimeZone.SwitchZone - PowerQuery M | Microsoft Docs

sorry I didn't know that

your solution works perfect


I wouldn't have been able to solve this on my own with Query M.

Thanks

Anonymous
Not applicable

Thanks,
but I don't got it to work

 

StartDate = "="&((Date(2022,6,10)-DATE(1970,1,1))*60*60*24)

 

doesn't recognize Date/DATE

 

Any hints 

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.

Top Solution Authors