Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
jamc
Frequent Visitor

Average running totals per row

Hi 

 

I am trying to find the following average Running result using for the following exercise:

 

WeekSALESAVERAGE FORMULA LOGIC

Desirable 

Result

W1100WK1 to WK13238
W2150WK2 to WK13250
W3200WK3 to WK13259
W4250WK4 to WK13265
W5300WK5 to WK13267
W6350WK6 to WK13263
W7400WK7 to WK13250
W8350WK8 to WK13225
W9300WK9 to WK13200
W10250WK10 to WK13175
W11200WK11 to WK13150
W12150WK12 to WK13125
W13100WK13 to WK13100

 

Any help would be appreciate it 

8 REPLIES 8
jamc
Frequent Visitor

Hi community i am still looking for the correct Dax Formula for the following excercise, is the only one left me to do  I have bieng different rolling average without  success, ill attach the logic of the excersice in green is the elements that i have in my model, in blue is the diserable result that i need populated in the same column, and in yelow the logic of the calculation please is the last thing I need to complete my project, I ll really apreciate it

ExampleExample

speedramps
Super User
Super User

Hi Jamc

 

Click here to download an example solution 

 

Add a index column because W1, W11, W12, !3 will sort before W2.

 

Then add DAX measure ... 

 

Result =
VAR CurrentWeek = SELECTEDVALUE(Facts[Index])   // gets the row week
RETURN
// get the average for all weeks >= the current week
CALCULATE(
AVERAGE(Facts[Sales]),                                
ALL(),
Facts[Index] >= CurrentWeek
)

I am an unpaid Power BI volunteer. Please click the thumbs up if you like me trying to help. Then click solved if this fixes your problem. Thank you.

Warm regards, speedramps

mahoneypat
Employee
Employee

Once you convert the Week column to integer (for example, with Text After Delimiter "W"), you can use a DAX measure like this one.

 

WkAvgSales =
VAR vThisWeek =
    MIN( WeeklySales[Week] )
VAR vResult =
    CALCULATE( AVERAGE( WeeklySales[SALES] ), WeeklySales[Week] >= vThisWeek )
RETURN
    vResult

 

mahoneypat_0-1650830263559.png

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Hi it was very Helpfull

 

But now I was asked for more compexity, I need to organize it by product and by date

 

ItemWEEKSalesDesirrable result
Product A4/18/2022 0:001040
Product A4/25/2022 0:001542.5
Product A5/2/2022 0:002045
Product A5/9/2022 0:002547.5
Product A5/16/2022 0:003050
Product A5/23/2022 0:003552.5
Product A5/30/2022 0:004055
Product A6/6/2022 0:004557.5
Product A6/13/2022 0:005060
Product A6/20/2022 0:005562.5
Product A6/27/2022 0:006065
Product A7/4/2022 0:006567.5
Product A7/11/2022 0:007070
Product B4/18/2022 0:006535
Product B4/25/2022 0:006032.5
Product B5/2/2022 0:005530
Product B5/9/2022 0:005027.5
Product B5/16/2022 0:004525
Product B5/23/2022 0:004022.5
Product B5/30/2022 0:003520
Product B6/6/2022 0:003017.5
Product B6/13/2022 0:002515
Product B6/20/2022 0:002012.5
Product B6/27/2022 0:001510
Product B7/4/2022 0:00107.5
Product B7/11/2022 0:0055

  

I was trying withs this formula but it didnt return the result that I wanted:

RR = VAR RRWEEK =
MIN('TRIAL VERSION'[Week] ) VAR RESULT = CALCULATE(AVERAGE('TRIAL VERSION'[SALES]), FILTER(ALLSELECTED('TRIAL VERSION'), 'TRIAL VERSION'[PRODUCT] = MIN('TRIAL VERSION'[PRODUCT] ) && 'TRIAL VERSION'[Week]<=RRWEEK)) RETURN RESULT
 
 
Thanks

Please explain how you got the result in the desired result column.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Ashish

 

It looks like Jamc has manually calulated the desired column,

by getting the average for


WK11 to WK13
WK12 to WK13
WK13 to WK13

etc  to etc

 

Speedramps and Mahoneypat both provided viable solutions to get the result using PBI.

Hi ASHISH

 

I leave the logic of the average calculation in an add last column

 

ItemWEEKSalesDesirrable resultAVERAGE FORMULA LOGIC
Product A4/18/20221040FROM Product A  WK1 TO WK 13
Product A4/25/20221542.5FROM Product A  WK2 TO WK 13
Product A5/2/20222045FROM Product A  WK3 TO WK 13
Product A5/9/20222547.5FROM Product A  WK4 TO WK 13
Product A5/16/20223050FROM Product A  WK5 TO WK 13
Product A5/23/20223552.5FROM Product A  WK6 TO WK 13
Product A5/30/20224055FROM Product A  WK7 TO WK 13
Product A6/6/20224557.5FROM Product A  WK8 TO WK 13
Product A6/13/20225060FROM Product A  WK9 TO WK 13
Product A6/20/20225562.5FROM Product A  WK10 TO WK 13
Product A6/27/20226065FROM Product A  WK11 TO WK 13
Product A7/4/20226567.5FROM Product A  WK12 TO WK 13
Product A7/11/20227070FROM Product A  WK13 TO WK 13
Product B4/18/20226535FROM Product B  WK1 TO WK 13
Product B4/25/20226032.5FROM Product B  WK2 TO WK 13
Product B5/2/20225530FROM Product B  WK3 TO WK 13
Product B5/9/20225027.5FROM Product B  WK4 TO WK 13
Product B5/16/20224525FROM Product B  WK5 TO WK 13
Product B5/23/20224022.5FROM Product B  WK6 TO WK 13
Product B5/30/20223520FROM Product B  WK7 TO WK 13
Product B6/6/20223017.5FROM Product B  WK8 TO WK 13
Product B6/13/20222515FROM Product B  WK9 TO WK 13
Product B6/20/20222012.5FROM Product B  WK10 TO WK 13
Product B6/27/20221510FROM Product B  WK11 TO WK 13
Product B7/4/2022107.5FROM Product B  WK12 TO WK 13
Product B7/11/202255FROM Product B  WK13 TO WK 13

 

hope you can help

 

regards

 

Hi,

I can help with solving this question is you can create a Calendar Table and in that table also have a week number column.  So please share the download link of your PBI file with your Data Table and the Calendar Table.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.