Forum Discussion

Ronie's avatar
Ronie
Frequent Visitor
10 years ago
Solved

Calculated Column - Display BST times for summer days only

Hi,  I'm pretty new to Power BI and I'm still struggling with its logic which I find quite different from excel. Any help would be great! Context I'm using Power BI to create a dashboard for my ...
  • jahida's avatar
    10 years ago

    Hi Ronnie,

     

    Try this:

     

    First, add this column to your date table:

     

    IsBST = 'Table 2'[Date] >= MAXX(FILTER('Table 2', 'Table 2'[Month Number] = 8 && 'Table 2'[DayofWeekNumber] = 1 && 'Table 2'[Year] = EARLIER('Table 2'[Year])), 'Table 2'[Date]) &&
    		'Table 2'[Date] < MAXX(FILTER('Table 2', 'Table 2'[Month Number] = 10 && 'Table 2'[DayofWeekNumber] = 1 && 'Table 2'[Year] = EARLIER('Table 2'[Year])), 'Table 2'[Date])

    That formula assumes that BST includes the last Sunday in August but not the last Sunday in October. Not sure if that's right or not, you can tweak the inequalities near the beginning of each line as needed. Then, you can use that to adjust the times in your other table.

     

    If you have relationships, you can use something like:

    DatetimeAdjusted = IF(RELATED('Table2'[IsBST]), Table1[Datetime] + 1/24, Table1[Datetime])

     

    If you don't have relationships (also going to assume you don't have a column with only the date), try instead:

     

    DatetimeAdjusted2 = IF(LOOKUPVALUE('Table 2'[IsBST], 'Table 2'[Date], DATE(YEAR(Table1[Datetime]), MONTH(Table1[Datetime]), DAY(Table1[Datetime]))),
    		Table1[Datetime] + 1/24, Table1[Datetime])

    Hope that helps, let me know how it goes!