Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Calculate difference and conditional column between two timeseries tables

Hi,

 

I have two tables where I want to calculate the difference and a conditional column between these tables, which should be filtererable for each category. Which means I want to be able to filter for each key with a slicer.

 

The difference should be between Value 1 and Value 2 for each timestamp.

The conditional calculation compares Value 1 and Value 2 in this way: if Value 1 > Value 2 then 1 else if Value 1<Value2 then -1 else 0

 

The following data is example data, real data consists of more keys and 1-2year of hourly data.

 

Table 1:

Date keyValue 1
2022-01-01 00:00:00 5005
2022-01-01 00:00:00 60010
2022-01-01 01:00:00 5002
2022-01-01 01:00:00 6006

 

Table 2:

Date keyValue 2
2022-01-01 00:00:00 7009
2022-01-01 00:00:00 80015
2022-01-01 01:00:00 70011
2022-01-01 01:00:00 80014

 

Table 3:

KeysTags
500Price 1
600Price 2
700Price 3
800Price 4

 

 

 

2 Replies

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

    Hi Anonymous ,

    I see that you have two tables with two values at one point in time, are the two values comparing the sum or?

    And what the table3 and keys in two tables work for ?

     

     

     

    Best Regards

    Lucien

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Lucien,

       

      For the conditional we compare for each point in time.

      So if we filter for key 500 and key 700, we should get:

      2022-01-01 00:00:00 -1
      2022-01-01 01:00:00 -1

       

      The third table is a dimensional table which can be used to connect table 1 and table 2.