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
caiodantas
Regular Visitor

Calculate the sales average by hour

Hi! 

I've been struggling to figure out how to calculate the information bellow. I would like to have an average of sales amount in an hour per distinct date. 

 

 

Sale Datetime Sale $ Sale Hour
08/03/2023 09:19     91 8
09/03/2023 09:23    95 8
09/03/2023 09:23    200 8
09/03/2023 09:28    180 8
08/03/2023 09:32     25 9
09/03/2023 09:07     108 9
09/03/2023 09:16     290 9
09/03/2023 09:31     107 9
09/03/2023 09:59     209 9
08/03/2023 09:49     175 9
08/03/2023 09:51     180 9
09/03/2023 09:45     263 9
09/03/2023 09:49     256 9
09/03/2023 09:36     44 9
09/03/2023 09:41     121 9
09/03/2023 09:43      45 9

 

In the data above, there are 4 sales at hour 8 (for my purpose, sale hour is 30 min before), three on March 9th and one on March 8th. When a do a simple measure to get an average per hour, the result is: 91+95+200+180 / 4 = 141.5 . However, since I need the average on distinct days, I was expecting 91 + 95 + 200 + 180 / 2, as there are only 2 different days.

 

May someone help me?

1 ACCEPTED SOLUTION
mrcss23
Advocate IV
Advocate IV

Hi. See if it helps

First in power query extract only date 

 

Sem título1.png

Sem título2.png

 

Then you can create a measure in DAX

 

Measure = sum(Tabela1[Sale $])/DISTINCTCOUNT(Tabela1[Date])
 
Create visual table with
* Sale hour (dont summarize)
* Measure
 
Sem título3.png

View solution in original post

3 REPLIES 3
mrcss23
Advocate IV
Advocate IV

Hi. See if it helps

First in power query extract only date 

 

Sem título1.png

Sem título2.png

 

Then you can create a measure in DAX

 

Measure = sum(Tabela1[Sale $])/DISTINCTCOUNT(Tabela1[Date])
 
Create visual table with
* Sale hour (dont summarize)
* Measure
 
Sem título3.png

Thanks @mrcss23 !
Worked like magic, did not know I just get date only.

 

Saved my life!

caiodantas
Regular Visitor

Already tried my best, but still could not find a solution

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.