Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
38 | |
26 | |
20 | |
15 | |
8 |
User | Count |
---|---|
69 | |
47 | |
46 | |
20 | |
16 |