Forum Discussion

RobbyLorenz3004's avatar
RobbyLorenz3004
Regular Visitor
2 years ago
Solved

Compare values

Hello everyone,

I have two tables (KPI and KPI_current day. Each table contains the respective date and time. Example: Column A = date and column B = 01:00:00. Column C contains integers. I would now like to compare these values ​​for the respective hour. So how big is the deviation (positive and negative) on the current day compared to the previous day. How can I implement this? Can anyone help me here?

  • Anonymous's avatar
    Anonymous
    2 years ago

    Thanks for the reply fromfahadqadir3, please allow me to provide another insight:

    HI,RobbyLorenz3004 

    Regarding the issue you raised, my solution is as follows:

    1.First I have created the following table and the column names and data are the data you have given:

    2. Below are the measure I've created for your needs:

     

    Measure = 
    var predate=SUM('Table'[date])-1
    var prevalue=CALCULATE(SUM('Table'[values]),FILTER(ALLSELECTED('Table'),'Table'[date]=predate&&'Table'[time]=MAX('Table'[time])))
    RETURN SUM('Table'[values])-prevalue

     

    3.Here's my final result, which I hope meets your requirements.

     

     

     

    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

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

     

3 Replies

  • fahadqadir3's avatar
    fahadqadir3
    Solution Supplier

    RobbyLorenz3004 Review the attached screenshot, i create a sample dataset with date and time column. I calculate the previous day value for same time.

     

    PreviousDayValue = 
    CALCULATE(
    MAX('Table'[value]),
    FILTER(
    'Table',
    'Table'[Date] = EARLIER('Table'[PreviousDay]) &&
    'Table'[Time] = EARLIER('Table'[Time])
    )
    )
    PreviousDay = 'Table'[Date] - 1

    Hope it works.

    Did I answer your question? Mark my post as a solution! This will help others on the forum!
    Appreciate your Kudos!! 

    • RobbyLorenz3004's avatar
      RobbyLorenz3004
      Regular Visitor

      Hallo, zunächst einmal vielen Dank. Ich habe das Datum 07.01.2024 in einer Spalte, dann 07.02.2024 usw. In der nächsten Spalte steht dann die Uhrzeit. Ab 00:00:00 - 23:00:00. In der nächsten Spalte befinden sich dann die Werte. In Ihrem Screenshot liegen die Tage und Uhrzeiten nebeneinander. Muss ich es so machen oder gibt es eine andere Möglichkeit, innerhalb meiner Struktur zu bleiben? Zum Beispiel möchte ich den 07/01/2024 08:00 Wert mit dem 07/02/2024 08:00 Wert vergleichen oder die Differenz anzeigen.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Thanks for the reply fromfahadqadir3, please allow me to provide another insight:

        HI,RobbyLorenz3004 

        Regarding the issue you raised, my solution is as follows:

        1.First I have created the following table and the column names and data are the data you have given:

        2. Below are the measure I've created for your needs:

         

        Measure = 
        var predate=SUM('Table'[date])-1
        var prevalue=CALCULATE(SUM('Table'[values]),FILTER(ALLSELECTED('Table'),'Table'[date]=predate&&'Table'[time]=MAX('Table'[time])))
        RETURN SUM('Table'[values])-prevalue

         

        3.Here's my final result, which I hope meets your requirements.

         

         

         

        Please find the attached pbix relevant to the case.

         

        Best Regards,

        Leroy Lu

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