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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
smpa01
Super User
Super User

DMV MDSCHEMA_CUBES

How can I have MDSCHEMA_CUBES in DMV to return the timestamps in EST. The results don't match to the refresh history at all.

 

Does any1 know why it returns a different timestamp altogether? I need it to return the exat same time stamp as refresh history of the dataset.

@jeffrey_wang @AlexisOlson @bcdobbs 

 

Thank you in advance.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
1 ACCEPTED SOLUTION

There is a way to convert the utc to client locale timestamp.

 

 $SYSTEM.MDSCHEMA_CUBES returns timestamp in utc as the pbi server is in utc. The Analysis server does not have any built-in server offset function either in DAX/MDX/DMV ( I would be very happy to be proved wrong). So therfore, there is no way to utilize any SSAS function to convert server timezone to a prefereed timezone LIKE MIGHTY SQL.

 

The first step is to create a datamart, even if there is no data ingested in it. The purpose of this datamart is to be able to take advantage of the SQL server that comes with it as SQL server has built-in TIMEZONE functions. So in my case I would do it like this

 

let
   col =  [dateTime]
   yr = Text.From(Date.Year(col)),
    month = Text.End("0"&Text.From(Date.Month(col)),2),
    day = Text.End("0"&Text.From(Date.Day(col)),2),
    hour = Text.End("0"&Text.From(Time.Hour(col)),2),
    minute = Text.End("0"&Text.From(Time.Minute(col)),2),
    second = Text.From(Time.Second(col)),    
    val = yr&"-"&month&"-"&day&" "&hour&":"&minute&":"&second 
   // 2024-05-31 17:07:41.373
   // could I have avoided generating val in PQ? yes, if DMV had support for CAST/CONVERT
  /* BUT The query engine for DMVs is the Data Mining parser. The DMV query syntax is based on the SELECT (DMX) statement. Although DMV query syntax is based on a SQL SELECT statement, it does not support the full syntax of a SELECT statement. Notably, JOIN, GROUP BY, LIKE, CAST, and CONVERT are not supported.*/
/* hence, PQ is required to generate val */
    in Sql.Database("server.datamart.fabric.microsoft.com", "db", [Query="select CONVERT(DATETIME,convert(datetime,'"&Text.From(val)&"') AT TIME ZONE 'UTC' AT TIME ZONE 'Eastern Standard Time') as t"])[t]{0}

 and this checks out on the server too

smpa01_0-1717178333312.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

View solution in original post

13 REPLIES 13
smpa01
Super User
Super User

@lbendlin  this is the best I could come up with, let me know if you have anything better

 

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMDJRMDSyMjAAIgVHX6XYWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Added Custom1" = Table.AddColumn(Source, "Custom", each [Column1]&" +00:00"),
    #"Changed Type2" = Table.TransformColumnTypes(#"Added Custom1",{{"Custom", type datetimezone}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type2", "Cust", each DateTimeZone.ToLocal([Custom])),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type datetimezone}})
in
    #"Changed Type1"

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

That will not help as "Local" for the Power BI service means "UTC". You need to supply the shift parameter.

 

@hackcrr 's approach is better but it will only work half of the year.

This works as long as it is used in semantic model and not in dataflow. This correctly intetprets client locale, but fails in dataflow. Power bi should have provided a method without needing me to explicitly provide the 3rd parameter for DateTimeZone.SwitchZone

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

there is no "client locale"  in a dataflow, nor in a Power BI service semantic model.  It is only applicable in a local PBIX or Excel file.

Yes, Iust realized that I jumped the gun on this. @lbendlin  is correct.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

There is a way to convert the utc to client locale timestamp.

 

 $SYSTEM.MDSCHEMA_CUBES returns timestamp in utc as the pbi server is in utc. The Analysis server does not have any built-in server offset function either in DAX/MDX/DMV ( I would be very happy to be proved wrong). So therfore, there is no way to utilize any SSAS function to convert server timezone to a prefereed timezone LIKE MIGHTY SQL.

 

The first step is to create a datamart, even if there is no data ingested in it. The purpose of this datamart is to be able to take advantage of the SQL server that comes with it as SQL server has built-in TIMEZONE functions. So in my case I would do it like this

 

let
   col =  [dateTime]
   yr = Text.From(Date.Year(col)),
    month = Text.End("0"&Text.From(Date.Month(col)),2),
    day = Text.End("0"&Text.From(Date.Day(col)),2),
    hour = Text.End("0"&Text.From(Time.Hour(col)),2),
    minute = Text.End("0"&Text.From(Time.Minute(col)),2),
    second = Text.From(Time.Second(col)),    
    val = yr&"-"&month&"-"&day&" "&hour&":"&minute&":"&second 
   // 2024-05-31 17:07:41.373
   // could I have avoided generating val in PQ? yes, if DMV had support for CAST/CONVERT
  /* BUT The query engine for DMVs is the Data Mining parser. The DMV query syntax is based on the SELECT (DMX) statement. Although DMV query syntax is based on a SQL SELECT statement, it does not support the full syntax of a SELECT statement. Notably, JOIN, GROUP BY, LIKE, CAST, and CONVERT are not supported.*/
/* hence, PQ is required to generate val */
    in Sql.Database("server.datamart.fabric.microsoft.com", "db", [Query="select CONVERT(DATETIME,convert(datetime,'"&Text.From(val)&"') AT TIME ZONE 'UTC' AT TIME ZONE 'Eastern Standard Time') as t"])[t]{0}

 and this checks out on the server too

smpa01_0-1717178333312.png

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs
hackcrr
Solution Sage
Solution Sage

Hi, @smpa01 

Handling Daylight Saving Time in Power Query, For a more accurate conversion that handles daylight saving time, you can use the DateTimeZone.SwitchZone function which can take into account daylight saving time if you specify the correct timezone identifier.

= DateTimeZone.SwitchZone([LAST_DATA_UPDATE], -5, 0)

 

Best Regards,

hackcrr

If this post helps, then please consider Accept it as the solution and kudos to this post to help the other members find it more quickly

lbendlin
Super User
Super User

Power BI Service runs on UTC.  Base all your reports on it too.

 

I am pretty sure you are not even on EST, but on EDT. 

@lbendlin  gr8 thnx, do you know how can I convert this tinestamp to client ttimestamp.

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

You don't.  Let the client's browser locale settings do it for you.

@lbendlin  I am sorry, I am not understanding. This is what i am currently getting, which is UTC. How do I let the browser local settings have it converted to EDT

 

smpa01_1-1716563572313.png

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

In your Power Query indicate that column as DateTimeZone and specify it as UTC.

 

RADACAD has a couple of articles on this topic.

@lbendlin how can I possibly specify it as UTC, I can do this, but how can you have it specified as utc?

 

Table.TransformColumnTypes(src,{{"last_schema_update", type datetimezone}})

the above returns 
12/20/2019 3:16:12 PM -05:00
which is client time zone of the last_schema_update, not utc

 

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors