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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
edejuan
New Member

Repeat 24 hours average for each day

Hi all,

First post here.

I’ve gathered the forum and part of Google. I've found similar topics, but I cannot make it work, I’d be grateful for your help.

 

I have an hourly time series in Power BI ('Date' and 'Price').
I need to fill a column ('Daily average') REPEATING each ROW the average of the 24h of that day, the key challenge is to change the average when the day changes.

I’ve been trying different approaches with AVERAGEX, VALUES… but I cannot get to find the solution.

It’s easier to see in this example from Excel: 

The 'Daily average' is the average of the 24 numbers in column 'Price'. 

edejuan_0-1655372245157.png

I'm completely stuck. How could I do it in Power BI (DAX)? 

Thank you very much. 
Best regards, 

Enrique

 

1 ACCEPTED SOLUTION

@edejuan Soooorry, a huge mistake!!

The correct formula:

 

= CALCULATE(AVERAGE(Prod_ES[Price]), ALLEXCEPT(Prod_ES,Prod_ES[date].[Date]))
 
the first one took into account only the day, but you have a lot of years and  months!
 
BF

View solution in original post

16 REPLIES 16
BeaBF
Solution Sage
Solution Sage

@edejuan Hi!

 

can you paste the data as a table and not an image?

 

BF

Hi @BeaBF 

Sure! Here you have. Thanks! 

 

DatePriceDaily average
19/05/2022 0:00179,94192,12
19/05/2022 1:00176,27192,12
19/05/2022 2:00177,98192,12
19/05/2022 3:00185,06192,12
19/05/2022 4:00222,33192,12
19/05/2022 5:00235,7192,12
19/05/2022 6:00230,01192,12
19/05/2022 7:00215,94192,12
19/05/2022 8:00198,22192,12
19/05/2022 9:00171,59192,12
19/05/2022 10:00167,02192,12
19/05/2022 11:00163,7192,12
19/05/2022 12:00161,18192,12
19/05/2022 13:00157,14192,12
19/05/2022 14:00157,14192,12
19/05/2022 15:00162,1192,12
19/05/2022 16:00164,54192,12
19/05/2022 17:00182192,12
19/05/2022 18:00220,43192,12
19/05/2022 19:00236,21192,12
19/05/2022 20:00226,03192,12
19/05/2022 21:00213,31192,12
19/05/2022 22:00211,1192,12
19/05/2022 23:00195,98192,12
20/05/2022 0:00189,56201,33
20/05/2022 1:00188201,33
20/05/2022 2:00189,56201,33
20/05/2022 3:00208,62201,33
20/05/2022 4:00226,51201,33
20/05/2022 5:00230,05201,33
20/05/2022 6:00230,72201,33
20/05/2022 7:00224201,33
20/05/2022 8:00204,97201,33
20/05/2022 9:00200,28201,33
20/05/2022 10:00195201,33
20/05/2022 11:00190,07201,33
20/05/2022 12:00180,18201,33
20/05/2022 13:00174201,33
20/05/2022 14:00180,18201,33
20/05/2022 15:00190201,33
20/05/2022 16:00214,92201,33
20/05/2022 17:00225,63201,33
20/05/2022 18:00226,87201,33
20/05/2022 19:00218,03201,33
20/05/2022 20:00205,27201,33
20/05/2022 21:00190,17201,33
20/05/2022 22:00180201,33
20/05/2022 23:00169,27201,33
21/05/2022 0:00169,26180,57
21/05/2022 1:00165,87180,57
21/05/2022 2:00164,84180,57
21/05/2022 3:00164,94180,57
21/05/2022 4:00164,84180,57
21/05/2022 5:00164,85180,57
21/05/2022 6:00166,54180,57
21/05/2022 7:00172,97180,57
21/05/2022 8:00178,82180,57
21/05/2022 9:00174,89180,57
21/05/2022 10:00170,57180,57
21/05/2022 11:00167,45180,57
21/05/2022 12:00164,67180,57
21/05/2022 13:00161,55180,57
21/05/2022 14:00159,33180,57
21/05/2022 15:00164,84180,57
21/05/2022 16:00171,58180,57
21/05/2022 17:00201180,57
21/05/2022 18:00219,32180,57
21/05/2022 19:00228,11180,57
21/05/2022 20:00227,05180,57
21/05/2022 21:00216,42180,57
21/05/2022 22:00214,57180,57
21/05/2022 23:00179,4180,57

 

 

(I'm having problems with posting, maybe my wifi, I've replied a couple of times but don't see my reply)

 

Thanks again

 

@edejuan You can calculate a column like this:

 

= CALCULATE(AVERAGE(Tabella[Price]), ALLEXCEPT(Tabella, Tabella[Date].[Giorno]))
 
BF

Hi @BeaBF 
Thank you very much for your formula. 

I'm afraid it doesn't work, it returns this: 

 

DatePriceDaily average
(expected result)
BeaBF
19/05/2022 0:00179,94192,1265,94
19/05/2022 1:00176,27192,1265,94
19/05/2022 2:00177,98192,1265,94
19/05/2022 3:00185,06192,1265,94
19/05/2022 4:00222,33192,1265,94
19/05/2022 5:00235,7192,1265,94
19/05/2022 6:00230,01192,1265,94
19/05/2022 7:00215,94192,1265,94
19/05/2022 8:00198,22192,1265,94
19/05/2022 9:00171,59192,1265,94
19/05/2022 10:00167,02192,1265,94
19/05/2022 11:00163,7192,1265,94
19/05/2022 12:00161,18192,1265,94
19/05/2022 13:00157,14192,1265,94
19/05/2022 14:00157,14192,1265,94
19/05/2022 15:00162,1192,1265,94
19/05/2022 16:00164,54192,1265,94
19/05/2022 17:00182192,1265,94
19/05/2022 18:00220,43192,1265,94
19/05/2022 19:00236,21192,1265,94
19/05/2022 20:00226,03192,1265,94
19/05/2022 21:00213,31192,1265,94
19/05/2022 22:00211,1192,1265,94
19/05/2022 23:00195,98192,1265,94
20/05/2022 0:00189,56201,3363,94
20/05/2022 1:00188201,3363,94
20/05/2022 2:00189,56201,3363,94
20/05/2022 3:00208,62201,3363,94
20/05/2022 4:00226,51201,3363,94
20/05/2022 5:00230,05201,3363,94
20/05/2022 6:00230,72201,3363,94
20/05/2022 7:00224201,3363,94
20/05/2022 8:00204,97201,3363,94
20/05/2022 9:00200,28201,3363,94
20/05/2022 10:00195201,3363,94
20/05/2022 11:00190,07201,3363,94
20/05/2022 12:00180,18201,3363,94
20/05/2022 13:00174201,3363,94
20/05/2022 14:00180,18201,3363,94
20/05/2022 15:00190201,3363,94
20/05/2022 16:00214,92201,3363,94
20/05/2022 17:00225,63201,3363,94
20/05/2022 18:00226,87201,3363,94
20/05/2022 19:00218,03201,3363,94
20/05/2022 20:00205,27201,3363,94
20/05/2022 21:00190,17201,3363,94
20/05/2022 22:00180201,3363,94
20/05/2022 23:00169,27201,3363,94
    

@edejuan no, i've just tried it and it works:

BeaBF_0-1655381638400.png

 

Can you paste your formula?

 

BF

Hi @BeaBF , thanks again for your patiente. 
This is my formula

= CALCULATE(AVERAGE('Tabla'[Price]), ALLEXCEPT('Tabla',Tabla[date].[Day]))
'Day' is in a Hierarchy in 'date'
 

@edejuan I have redone the formula and it works:

BeaBF_0-1655382379333.png

 

can you paste a screen?

 

BF

Hi @BeaBF , 

Here's a screenshot. I've overlayed in red the expected result. 
I'm scratching my head. I don't understand. 

edejuan_0-1655383666419.png

 

When done in a small dataset, your formula works OK 🙂
Buen when I apply it to the 65k rows model, it doesn't. 
Mystery! 

 

 

@edejuan The field date is in datetime type, right? uhmmm 

Yes. 

edejuan_0-1655384154936.png

Totally lost here...

 

@edejuan ok, plan B. Can you send me your pbix? 

Hi @BeaBF, I've sent you a Wetransfer link via private message. 

Thanks for your help!!!

@edejuan Soooorry, a huge mistake!!

The correct formula:

 

= CALCULATE(AVERAGE(Prod_ES[Price]), ALLEXCEPT(Prod_ES,Prod_ES[date].[Date]))
 
the first one took into account only the day, but you have a lot of years and  months!
 
BF

IT WORKS!!! 

Thank you thank you thank you @BeaBF , you're simply the best!!! 🙂 

Sure! 

Sorry! There you have. 

Thanks!! 

 

 

DatePriceDaily average
19/05/2022 0:00179,94192,12
19/05/2022 1:00176,27192,12
19/05/2022 2:00177,98192,12
19/05/2022 3:00185,06192,12
19/05/2022 4:00222,33192,12
19/05/2022 5:00235,7192,12
19/05/2022 6:00230,01192,12
19/05/2022 7:00215,94192,12
19/05/2022 8:00198,22192,12
19/05/2022 9:00171,59192,12
19/05/2022 10:00167,02192,12
19/05/2022 11:00163,7192,12
19/05/2022 12:00161,18192,12
19/05/2022 13:00157,14192,12
19/05/2022 14:00157,14192,12
19/05/2022 15:00162,1192,12
19/05/2022 16:00164,54192,12
19/05/2022 17:00182192,12
19/05/2022 18:00220,43192,12
19/05/2022 19:00236,21192,12
19/05/2022 20:00226,03192,12
19/05/2022 21:00213,31192,12
19/05/2022 22:00211,1192,12
19/05/2022 23:00195,98192,12
20/05/2022 0:00189,56201,33
20/05/2022 1:00188201,33
20/05/2022 2:00189,56201,33
20/05/2022 3:00208,62201,33
20/05/2022 4:00226,51201,33
20/05/2022 5:00230,05201,33
20/05/2022 6:00230,72201,33
20/05/2022 7:00224201,33
20/05/2022 8:00204,97201,33
20/05/2022 9:00200,28201,33
20/05/2022 10:00195201,33
20/05/2022 11:00190,07201,33
20/05/2022 12:00180,18201,33
20/05/2022 13:00174201,33
20/05/2022 14:00180,18201,33
20/05/2022 15:00190201,33
20/05/2022 16:00214,92201,33
20/05/2022 17:00225,63201,33
20/05/2022 18:00226,87201,33
20/05/2022 19:00218,03201,33
20/05/2022 20:00205,27201,33
20/05/2022 21:00190,17201,33
20/05/2022 22:00180201,33
20/05/2022 23:00169,27201,33

 

Sure @BeaBF ! 

There you have. 

Thanks!! 

 

 

DatePriceDaily average
19/05/2022 0:00179,94192,12
19/05/2022 1:00176,27192,12
19/05/2022 2:00177,98192,12
19/05/2022 3:00185,06192,12
19/05/2022 4:00222,33192,12
19/05/2022 5:00235,7192,12
19/05/2022 6:00230,01192,12
19/05/2022 7:00215,94192,12
19/05/2022 8:00198,22192,12
19/05/2022 9:00171,59192,12
19/05/2022 10:00167,02192,12
19/05/2022 11:00163,7192,12
19/05/2022 12:00161,18192,12
19/05/2022 13:00157,14192,12
19/05/2022 14:00157,14192,12
19/05/2022 15:00162,1192,12
19/05/2022 16:00164,54192,12
19/05/2022 17:00182192,12
19/05/2022 18:00220,43192,12
19/05/2022 19:00236,21192,12
19/05/2022 20:00226,03192,12
19/05/2022 21:00213,31192,12
19/05/2022 22:00211,1192,12
19/05/2022 23:00195,98192,12
20/05/2022 0:00189,56201,33
20/05/2022 1:00188201,33
20/05/2022 2:00189,56201,33
20/05/2022 3:00208,62201,33
20/05/2022 4:00226,51201,33
20/05/2022 5:00230,05201,33
20/05/2022 6:00230,72201,33
20/05/2022 7:00224201,33
20/05/2022 8:00204,97201,33
20/05/2022 9:00200,28201,33
20/05/2022 10:00195201,33
20/05/2022 11:00190,07201,33
20/05/2022 12:00180,18201,33
20/05/2022 13:00174201,33
20/05/2022 14:00180,18201,33
20/05/2022 15:00190201,33
20/05/2022 16:00214,92201,33
20/05/2022 17:00225,63201,33
20/05/2022 18:00226,87201,33
20/05/2022 19:00218,03201,33
20/05/2022 20:00205,27201,33
20/05/2022 21:00190,17201,33
20/05/2022 22:00180201,33
20/05/2022 23:00169,27201,33

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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

Top Kudoed Authors