Search code examples
powerbidax

How to stop the line graph at a certain point when the data stalls


I have cumulative sum of ticketed sales data by every month that is plotted for every day. X axis is number of days (day 200, day 201). I have plotted a measure which does the cumulative sum

  CALCULATE (
  SUM ( 'Sales'[Apr-2023] ),
  FILTER ( All('Sales'),
  'Sales'[Days To Event] >= Max('Sales'[Days To Event]
  )
  ))

I would like the data for months where the ticketed sales stalls to stop the line. Is there a way to use If statement combined with this measure? Or add a filter on the page like a flag to say if the sales data = sales data as previous day it should stop?

enter image description here


Solution

  • You could say if there are no sales on that date then stop. Try something like:

    my measure = 
      var result =
        CALCULATE (
          SUM ( 'Sales'[Apr-2023] ),
          FILTER (
            All('Sales'),
           'Sales'[Days To Event] >= MAX('Sales'[Days To Event])
          )
        )
      return
        IF( SUM( 'Sales'[Apr-2023] ) > 0, result)