Forum Discussion

CarlosOlmos29's avatar
2 years ago

Add two measures after a date

Hello Power BI Community.

I am trying to sum two DAX measures, but I need them to be summed only after a certain date (after the line in the image). I tried with an if but it didn't work. I would appreciate if you can give me some ideas to solve this problem.

The measures are SUM OIL REAL(BLS) and FCST OIL.

Thanks in advance for your support.

 

7 Replies

  • CarlosOlmos29 You can use the below measure to achieve your result, in my case I took the date after 2-Jan-2024, likewise you can write your expected date value.

    Measure = CALCULATE(SUM('Table'[Value1])+SUM('Table'[Value2]),FILTER('Table','Table'[Date]>DATE(2024,1,2)))

     

     

     

    • CarlosOlmos29's avatar
      CarlosOlmos29
      Helper I

      It worked with the date, but it is not adding up the measurements. It looks like the screenshot below.

       

      This is the measure I am using:

      Real + fcst = CALCULATE([SUMA OIL REAL(BLS)] + [FCST OIL],FILTER(Consolidado, Consolidado[VOLUME_DATE] > MAX(Real[VOLUME_DATE])))
      I think it is not adding up because the SUMA OIL REAL(BLS) data is being repeated after March 15. Actually there is no more data entered after that date. We could modify the measurement so that the last data of March 15 of SUMA OIL REAL is added with the one of April 15 of FCST OIL.
  • I may be miss understanding but can you not just add a date filter?

    • CarlosOlmos29's avatar
      CarlosOlmos29
      Helper I

      How? I tried to use the next measure:

      Real + fcst = CALCULATE([SUMA OIL REAL(BLS)] + [FCST OIL],Consolidado[VOLUME_DATE] >= [FechaCorte])
      ([FechaCorte] is the date from which I want the measurements to start adding up) 
      But the measurement gives me an error
  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi CarlosOlmos29 ,

    I create a table and two measures as you mentioned.

    Then I create a measure and here is the DAX code.

     

    Measure = 
    CALCULATE (
        'Table'[Measure1] + 'Table'[Measure2],
        FILTER ( 'Table', 'Table'[Date] > DATE ( 2024, 1, 2 ) )
    )

     

     

     

     

    Best Regards

    Yilong Zhou

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