Forum Discussion
Anonymous
6 years agoNot applicable
Power BI - timezone
Hi, I am trying to think of a function or conditional column that I am able to use for the following situation: Employee works 2/16 at 11:00pm (CST) and clocks in at 11:01:29 PM equals late ...
- 6 years ago
In my next book coming out this month, I have a recipe for time zone conversion. Here is a brief excerpt from DAX Cookbook by Packt coming out this month. See if it helps.
To prepare for this recipe, do the following:
- Open Power BI Desktop and create a table called R09_Timezones by importing the file Timezones.csv file from GitHub here: https://github.com/gdeckler/DAXCookbook/Ch03
- Use and Enter Data query to create a table called R09_Table with the following data:
Time Timezone 1:00:00 PM EST - Ensure that the Data type for the Time column is set to Time
- Create a relationship between the Timezone column in the table R09_Table and the Abbr. column in the table R09_Timezones
How to do it...
To implement this recipe, do the following:
- Create a column in the table R09_Timezones with the following formula:
DAX UTC Offset = [UTC Offset] / 24- Create a measure using the following formula:
TZ Convert =
VAR __DestTZ = "ACWST"
VAR __SourceTime = MAX('R09_Table'[Time])
VAR __SourceTZ = MAX('R09_Table'[Timezone])
VAR __SourceOffset =
LOOKUPVALUE(
'R09_Timezones'[DAX UTC Offset],
'R09_Timezones'[Abbr.],
__SourceTZ
)
VAR __DestOffset =
LOOKUPVALUE(
'R09_Timezones'[DAX UTC Offset],
'R09_Timezones'[Abbr.],
__DestTZ
)
VAR __UTCTime = __SourceTime + -1 * __SourceOffset
RETURN
IF(
ISBLANK(__SourceTime),
BLANK(),
__UTCTime + __DestOffset
)- Create a Table visualization and place the Time and Timezone columns from the table R09_Table as well as the measure TZ Convert into the Values field for this visualization
Greg_Deckler
6 years agoCommunity Champion
In my next book coming out this month, I have a recipe for time zone conversion. Here is a brief excerpt from DAX Cookbook by Packt coming out this month. See if it helps.
To prepare for this recipe, do the following:
- Open Power BI Desktop and create a table called R09_Timezones by importing the file Timezones.csv file from GitHub here: https://github.com/gdeckler/DAXCookbook/Ch03
- Use and Enter Data query to create a table called R09_Table with the following data:
| Time | Timezone |
| 1:00:00 PM | EST |
- Ensure that the Data type for the Time column is set to Time
- Create a relationship between the Timezone column in the table R09_Table and the Abbr. column in the table R09_Timezones
How to do it...
To implement this recipe, do the following:
- Create a column in the table R09_Timezones with the following formula:
DAX UTC Offset = [UTC Offset] / 24
- Create a measure using the following formula:
TZ Convert =
VAR __DestTZ = "ACWST"
VAR __SourceTime = MAX('R09_Table'[Time])
VAR __SourceTZ = MAX('R09_Table'[Timezone])
VAR __SourceOffset =
LOOKUPVALUE(
'R09_Timezones'[DAX UTC Offset],
'R09_Timezones'[Abbr.],
__SourceTZ
)
VAR __DestOffset =
LOOKUPVALUE(
'R09_Timezones'[DAX UTC Offset],
'R09_Timezones'[Abbr.],
__DestTZ
)
VAR __UTCTime = __SourceTime + -1 * __SourceOffset
RETURN
IF(
ISBLANK(__SourceTime),
BLANK(),
__UTCTime + __DestOffset
)
- Create a Table visualization and place the Time and Timezone columns from the table R09_Table as well as the measure TZ Convert into the Values field for this visualization