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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.