Forum Discussion

mhasler's avatar
mhasler
Frequent Visitor
6 years ago
Solved

Slicing a moving average

This was a great help and works but the measure doesn't slice with the other value in the same visualization which does slice - by state.
https://community.powerbi.com/t5/Desktop/Moving-Average/m-p/1097929

 

I don't think I've made a measure before that won't slice by whatever field in the dataset I've set up a slicer.

On the upside this data is publicly available on the CovidTrackingProject site: https://covidtracking.com/data/api 

 

This is the measure - works but won't slice by state:

 

Positive Rolling AVG - 7 days =
CALCULATE (
SUM (StatesDaily[positiveIncrease]) / 7,
DATESINPERIOD (
StatesDaily[DateText],
LASTDATE ( StatesDaily[DateText] ),
-7,
DAY
),
FILTER (
ALL (StatesDaily ),
MAX ( StatesDaily[DateText] ) < TODAY ()
)
)
 
All states (unsliced)

Sliced to a state - note the moving avg stays the same and the other measure slices correctly

 

 

 

  • mhasler change ALL  to ALLSELECTED

     

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.

2 Replies

  • mhasler change ALL  to ALLSELECTED

     

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.

    • mhasler's avatar
      mhasler
      Frequent Visitor

      in the process of trying ALLSELECTED instead of ALL, I ended up needing to just delete the filter to start clean.

      I happened to notice that made it slice properly and I didn't need the date filter in the first place since the data does not have any future dates to filter out like the example this came from.

      Now I get a proper measure when sliced/unsliced!

      Thanks!