Forum Discussion
aggregate measure based on future week number
Hi All,
Column 1 is week number and Column 2 is the total sales per week.
I am trying to created Column 3 , which is average of future 4 weeks , including the current week value.
Thank you very much
- Anonymous6 years ago
Fowmy nandukrishnavs Thank you very much for support and help here.
Final measure looks like as below and generates the desired result as shared in my original post.
Future_Forecast =VAR _CURRENTWEEK = SELECTEDVALUE('Date'[Week Num])VAR _DATE = FILTER(ALL('Date'[Week Num]),'Date'[Week Num] >= _CURRENTWEEK && 'Date'[Week Num] <= _CURRENTWEEK + 3)RETURNAVERAGEX(_DATE, [Weekly_Forecast]) Anonymous
Great!
You can now accept the reply as a solution and click on the Thumbs-Sup icon if you like it.
ThanksFowmy
13 Replies
- nandukrishnavs
Community Champion
Anonymous
If you are looking for a calculated column, use below DAX.
FutureAVG = AVERAGEX ( FILTER ( Table1, Table1[Week No] < EARLIER ( Table1[Week No] ) + 4 && Table1[Week No] >= EARLIER ( Table1[Week No] ) ), Table1[Weekly Forecast] )If you are looking for a measure, use below DAX.
FutureAVGMeasure = VAR __currentweek = SELECTEDVALUE ( Table1[Week No] ) VAR __result = AVERAGEX ( FILTER ( ALL ( Table1 ), Table1[Week No] < __currentweek + 4 && Table1[Week No] >= __currentweek ), Table1[Weekly Forecast] ) RETURN __result
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂- AnonymousNot applicable
nandukrishnavs : Thanks for the response, but this is not working for now. Can you please suggest as per below
First row output should be = (24+45+23+67) / 4 = 39.75....i.e Average(w1,w2,w3,w4) , Second row Average(w2,w3,w4,w5).....so on
I will prefer measure.. Thanks
I tired to modify a bit , but not working still :
FutureAVGMeasure =
VAR __currentweek =SELECTEDVALUE ('Date'[Week Num])VAR __result =AVERAGEX (FILTER ('Date' ,// 'Date'[Week Num] <= __currentweek + 3,'Date'[Week Num] >= __currentweek && 'Date'[Week Num] <= __currentweek + 3),[Weekly_Forecast])RETURN__result
- Fowmy
Super User
Anonymous
Add this as a new column:Future Avg Forecast Sales = VAR _CURRENTWEEK = [Week No] VAR _DATE = FILTER( 'Table 2', 'Table 2'[Week No]>= _CURRENTWEEK && 'Table 2'[Week No] <= _CURRENTWEEK + 3 ) RETURN IF( COUNTROWS(_DATE)<4,BLANK(), AVERAGEX( _DATE, 'Table 2'[Weekly_Forecast] ) )________________________
Did I answer your question? Mark this post as a solution, this will help others!.
Click on the Thumbs-Up icon on the right if you like this reply 🙂
- AnonymousNot applicable
Fowmy I need a Measure, I tried with modification but it did not work.
I made the follwing changes :Future Avg Forecast Sales =VAR _CURRENTWEEK = SELECTEDVALUE('Date'[Week Num])VAR _DATE = FILTER(ALL('Date'[Week Num]),'Date'[Week Num] >= _CURRENTWEEK && 'Date'[Week Num] <= _CURRENTWEEK + 3)RETURNIF(COUNTROWS(_DATE) < 4, BLANK(),AVERAGEX(_DATE,[Weekly_Forecast]))- Fowmy
Super User
Anonymous
Try:Avg Measure = VAR _CURRENTWEEK = SELECTEDVALUE('DATE'[Week No]) VAR _DATE = FILTER( 'DATE', 'DATE'[Week No]= _CURRENTWEEK && 'DATE'[Week No] <= _CURRENTWEEK + 3 ) RETURN IF( COUNTROWS(_DATE)<4,BLANK(), AVERAGEX( _DATE, SUM('Table 2'[Weekly_Forecast]) ) )________________________
Did I answer your question? Mark this post as a solution, this will help others!.
Click on the Thumbs-Up icon on the right if you like this reply 🙂
- AnonymousNot applicable
Fowmy At column level, it gives me average of all the Product in my table.
How can I filter based on the Product --> Week --> AVERAGEX
Is it also dependednt on the Data Model ?I tried the following, using ALLSELECTED ?
Future Avg Forecast Sales = VAR _CURRENTWEEK = [Week No] VAR _DATE = FILTER( ALLSELECTED('Table 2', ProductName), 'Table 2'[Week No]>= _CURRENTWEEK && 'Table 2'[Week No] <= _CURRENTWEEK + 3 ) RETURN IF( COUNTROWS(_DATE)<4,BLANK(), AVERAGEX( _DATE, 'Table 2'[Weekly_Forecast] ) )- Fowmy
Super User
Anonymous
I am not sure about the issue you are facing now. Can you explain further or share the PBIX file with the expected results.________________________
Did I answer your question? Mark this post as a solution, this will help others!.
Click on the Thumbs-Up icon on the right if you like this reply 🙂