Forum Discussion
cosminc
Post Partisan
7 years agoRolling Average last 2 months data
Hi all,
i need to calculate a rolling average from a table but split on a dimension items
i tried this:
https://community.powerbi.com/t5/Desktop/Rolling-average-on-calculated-table/m-p/693382#M334402
but in my case the relationship Calendar - Base is inverted; on my base there are Many same Date, not unique
The calendar is marked as Date Table
please load as example the table form below:
| Date | Year | Month | Client | Value | Rolling AVERAGE - expected |
| 1-Jan-2018 | 2018 | 1 | cosmin | 90.0 | 90 |
| 1-Feb-2018 | 2018 | 2 | cosmin | 30.0 | 60 |
| 1-Mar-2018 | 2018 | 3 | cosmin | 30.0 | 30 |
| 1-Apr-2018 | 2018 | 4 | cosmin | 80.0 | 55 |
| 1-May-2018 | 2018 | 5 | cosmin | 80.0 | 80 |
| 1-Jun-2018 | 2018 | 6 | cosmin | 100.0 | 90 |
| 1-Jul-2018 | 2018 | 7 | cosmin | 50.0 | 75 |
| 1-Aug-2018 | 2018 | 8 | cosmin | 60.0 | 55 |
| 1-Sep-2018 | 2018 | 9 | cosmin | 60.0 | 60 |
| 1-Oct-2018 | 2018 | 10 | cosmin | 70.0 | 65 |
| 1-Nov-2018 | 2018 | 11 | cosmin | 60.0 | 65 |
| 1-Dec-2018 | 2018 | 12 | cosmin | 60.0 | 60 |
| 1-Jan-2018 | 2018 | 1 | marius | 20.0 | 20 |
| 1-Feb-2018 | 2018 | 2 | marius | 70.0 | 45 |
| 1-Mar-2018 | 2018 | 3 | marius | 30.0 | 50 |
| 1-Apr-2018 | 2018 | 4 | marius | 20.0 | 25 |
| 1-May-2018 | 2018 | 5 | marius | 10.0 | 15 |
| 1-Jun-2018 | 2018 | 6 | marius | 10.0 | 10 |
| 1-Jul-2018 | 2018 | 7 | marius | 60.0 | 35 |
| 1-Aug-2018 | 2018 | 8 | marius | 90.0 | 75 |
| 1-Sep-2018 | 2018 | 9 | marius | 30.0 | 60 |
| 1-Oct-2018 | 2018 | 10 | marius | 30.0 | 30 |
| 1-Nov-2018 | 2018 | 11 | marius | 30.0 | 30 |
| 1-Dec-2018 | 2018 | 12 | marius | 20.0 | 25 |
| 1-Jan-2018 | 2018 | 1 | ana | 20.0 | 20 |
| 1-Feb-2018 | 2018 | 2 | ana | 10.0 | 15 |
| 1-Mar-2018 | 2018 | 3 | ana | 100.0 | 55 |
| 1-Apr-2018 | 2018 | 4 | ana | 20.0 | 60 |
| 1-May-2018 | 2018 | 5 | ana | 80.0 | 50 |
| 1-Jun-2018 | 2018 | 6 | ana | - | 40 |
| 1-Jul-2018 | 2018 | 7 | ana | 20.0 | 10 |
| 1-Aug-2018 | 2018 | 8 | ana | 100.0 | 60 |
| 1-Sep-2018 | 2018 | 9 | ana | 50.0 | 75 |
| 1-Oct-2018 | 2018 | 10 | ana | 30.0 | 40 |
| 1-Nov-2018 | 2018 | 11 | ana | 90.0 | 60 |
| 1-Dec-2018 | 2018 | 12 | ana | 10.0 | 50 |
Thanks,
Cosmin
1 Reply
- cosminc
Post Partisan
another solution can be something like this:
VAR _current_date = base[Date]VAR _previous_date = i don't know how to obtain it - isVAR _Months = { _current_date, _previous_date }VAR result = CALCULATE(SUM(base[Value]), ALLEXCEPT(base, base[Client]) && base[Date] IN _Months))/RETURNresulti don't know how to use those 2 filters and obtain the right expression: ALLEXCEPT(base, base[Client]) && base[Date] IN _Months)
tip: column date has only one value for each year month client (1st of the month)
thanks,
Cosmin