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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
tarasic
Frequent Visitor

Calculate the percentage based on the summs of hourly sales and their daily and weekly averages.

I have a dataset with the following columns:
Date
Time
units sold
week#
hour

I need to calculate the difference between the hourly sales and their total daily and weekly averages.

tarasic_0-1743768074900.png

 

Where:
1 - SUM of sales by hours
2 - daily AVERAGES of these SUMS by hours
3 - AVERAGE of ALL hourly sales in a week

 

tarasic_2-1743768288597.png

4 - result of division of every 1 (SUM of sales by hours) by 3 (total AVERAGE of ALL hourly sales in a week)


I can make the first step by this measure:

AvgPerDaySumByHour =
VAR _DailySoldByHour =
    SUMMARIZECOLUMNS(
        DimDate[Week+Day+Short],
        data[Time (hours)],
        "TotalSold", SUM(data[units sold])
    )
RETURN
AVERAGEX(_DailySoldByHour, [TotalSold])
 
And get the same table in Power BI.
tarasic_3-1743768568887.png

I don't understand how to get my "total averages" 3 from this table, to calculate %. 


You can find the sample PBIX here.

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Here is how you calculate #3

AvgPerWeek = 
VAR _DailySoldByHour = 
    SUMMARIZECOLUMNS(
        DimDate[Week+Day+Short], 
        data[Time (hours)],
    allexcept(DimDate,DimDate[WeekNumber]),
    REMOVEFILTERS(data[Time (hours)]),
        "TotalSold", SUM(data[units sold])
    )
RETURN
AVERAGEX(_DailySoldByHour, [TotalSold])

 

and then you can do the percentage accordingly.

View solution in original post

2 REPLIES 2
tarasic
Frequent Visitor

Thanks!!!

lbendlin
Super User
Super User

Here is how you calculate #3

AvgPerWeek = 
VAR _DailySoldByHour = 
    SUMMARIZECOLUMNS(
        DimDate[Week+Day+Short], 
        data[Time (hours)],
    allexcept(DimDate,DimDate[WeekNumber]),
    REMOVEFILTERS(data[Time (hours)]),
        "TotalSold", SUM(data[units sold])
    )
RETURN
AVERAGEX(_DailySoldByHour, [TotalSold])

 

and then you can do the percentage accordingly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.