Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Dear Community,
Could you help me to adjust the DAX formula oF Rolling Avg 2Q yellow line to exclude the start point which is not enough data (2 quarter ) to calculate properly and the end point (2023Q2) as below ?
Rolling Avg 2Q =
VAR NumOfQuarters = 2
VAR LastCurrentDate =
MAX(DimDates[Date])
VAR Period =
DATESINPERIOD (DimDates[Date], LastCurrentDate, - NumOfQuarters, QUARTER )
VAR Result =
CALCULATE (
'Value/Qty Selection'[Value/Quantity]
/2,
Period
)
RETURN
Result
Hi,
I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
I hope the below can provide some ideas on how to create a solution for your datamodel.
Qty total: =
SUM( Sales[Quantity] )
Qty 2months rolling avg: =
VAR _currentrowquarterend =
MAX ( 'Calendar'[End of Quarter] )
VAR _conditiontable =
FILTER (
ADDCOLUMNS (
FILTER (
ALL ( 'Calendar'[End of Quarter], 'Calendar'[Year-Quarter] ),
'Calendar'[End of Quarter] <= _currentrowquarterend
),
"qty", [Qty total:]
),
[qty] <> BLANK ()
)
VAR _condition =
COUNTROWS ( _conditiontable ) >= 2
&& [Qty total:] <> BLANK ()
&& HASONEVALUE ( 'Calendar'[Year-Quarter] )
RETURN
DIVIDE ( _condition, _condition )
* CALCULATE (
[Qty total:],
WINDOW (
-1,
REL,
0,
REL,
ALL ( 'Calendar'[End of Quarter], 'Calendar'[Year-Quarter] ),
ORDERBY ( 'Calendar'[End of Quarter], ASC )
)
) / 2
User | Count |
---|---|
12 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
24 | |
19 | |
14 | |
10 | |
7 |