Forum Discussion

joshua1990's avatar
joshua1990
Icon for Post Prodigy rankPost Prodigy
4 years ago
Solved

Show Past based on selected Week

Hi experts!

I have a simple bar chart that shows our Sales per Week.

Now I would like to add a slicer / filter to select the last week that should be include into the chart.

For instance, when I select Week 22 I just want to see all sales until week 22.

How can I do this using dax?

THis approach doesn't work:

CALCULATE (
        [Sales],
        FILTER (
            ALL ( 'Calendar' ),
            'Calendar'[Year] = VALUES ( 'Calendar'[Year] )
                && 'Calendar'[Week] <= MAX ( 'Calendar'[Week] )
        )
    )
  • Try

    Sales up to week =
    var maxDate = MAX('Calendar'[Date])
    return CALCULATE( [Sales], REMOVEFILTERS('Calendar'), 'Calendar'[Date] <= maxDate )

5 Replies

  • Try

    Sales up to week =
    var maxDate = MAX('Calendar'[Date])
    return CALCULATE( [Sales], REMOVEFILTERS('Calendar'), 'Calendar'[Date] <= maxDate )
    • joshua1990's avatar
      joshua1990
      Icon for Post Prodigy rankPost Prodigy

      Thanks johnt75 , bot nothing changes. I still see just 1 week if I filter on the slicer on 1 week.

       

    • joshua1990's avatar
      joshua1990
      Icon for Post Prodigy rankPost Prodigy

      Ok, I have found the issue.

      Now I get the sum of all past weeks display in the selected week.

      Just 1 week is displayed in the visual but is sums all past weeks. How can I get the value per week for each week?

      • johnt75's avatar
        johnt75
        Icon for Super User rankSuper User

        I would think your normal [Sales] measure would do that

  • Use Performance Analyser to get the DAX code generated for the visual, check what filters are being applied in there.