Forum Discussion

evolve_Tricia's avatar
5 years ago
Solved

Calculated column for dynamic time zone

Hi,
I need to create a calculated column for dynamic time zone conversion when a specific time zone is created. 

 

There is a table with time zone and time difference from UTC. 

 

I have a table of orders as below, with order_id, original dates of orders. 
time_diff is a measure:

 

time_diff = IF(
    ISFILTERED('Time Zones'[Time Zone]),
     TIME(DISTINCT('Time Zones'[Time Diff from UTC]), 0, 0)
)

 

 

date_converted is a calculated column

 

date_converted = FORMAT('orders'[date_original]+[time_diff], "General Date")

 

 

This is the expected results

order_iddate_originaltime_diffdate_converted
12020/10/11 2:00 AM08:00:002020/10/11 10:00 AM
22020/10/11 8:00 AM08:00:002020/10/11 4:00 PM
32020/10/11 2:00 PM08:00:002020/10/11 10:00 PM
42020/10/11 8:00 PM08:00:002020/10/12 4:00 AM
52020/10/12 2:00 AM08:00:002020/10/12 10:00 AM
62020/10/12 8:00 AM08:00:002020/10/12 4:00 PM
72020/10/12 2:00 PM08:00:002020/10/12 10:00 PM
82020/10/12 8:00 PM08:00:002020/10/13 4:00 AM
92020/10/13 2:00 AM08:00:002020/10/13 10:00 AM
102020/10/13 8:00 AM08:00:002020/10/13 4:00 PM
112020/10/13 2:00 PM08:00:002020/10/13 10:00 PM
122020/10/11 2:00 AM08:00:002020/10/11 10:00 AM
132020/10/11 8:00 AM08:00:002020/10/11 4:00 PM

 

However, the date converted didn't change at all! What could be the problem?

  • Hi evolve_Tricia ,

     

    If you want dynamic, you need to change the calculate column to measure.

    Please refer this measure.

     

    date_converted = FORMAT(MAX(orders[date_original])+[time_diff], "General Date")

     

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

     

    Best regards,

     

    Community Support Team _ zhenbw

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

     

    BTW, pbix as attached.

2 Replies

  • Calculated Column <> Dynamic

     

    A calculated column is a static value.  You will want to use a measure instead, or rethink your logic.

  • v-zhenbw-msft's avatar
    v-zhenbw-msft
    Community Support

    Hi evolve_Tricia ,

     

    If you want dynamic, you need to change the calculate column to measure.

    Please refer this measure.

     

    date_converted = FORMAT(MAX(orders[date_original])+[time_diff], "General Date")

     

     

     

    If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

     

    Best regards,

     

    Community Support Team _ zhenbw

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

     

    BTW, pbix as attached.