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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
A_Scott
Helper I
Helper I

How to calculate completion over a rolling 7 days?

I have the following 2 calculations:

This one calculates how many inpsections are done to bakery ovens. It is used in a matrix that shows locations in the rows, date set to rolling 7 days in the columns, and the counts from the below calculation as the values.

Complete Bakery Oven Inspections = CALCULATE(
       COUNTA('BAKERY_OVEN_INSPECTION_LOG_DETAIL'[OVEN_INSPECTION_ID]))
The next calculation I have shows the total percent complete for the same rolling 7 days and is as follows:
% Bakery Oven Inspections Complete = IF([Oven Count]=0,
"N/A",
IF(
    ISINSCOPE('Open Locations'[Division-Store]),
    MIN(1,([Complete Bakery Oven Inspections]/([Oven Count]*7))),
    AVERAGEX(
        VALUES('Open Locations'[Division-Store]),
        MIN(1,[Complete Bakery Oven Inspections]/([Oven Count]*7))
    )
)
)
The problem I'm having is that my percent complete calculation does differientiate if a location does all of their inspections on a single day, or does one inspection each day as is required. So any location go falsely show 100% complete if as long as they did the 7. I want to calculate that each location is 100% complete each day, so I guess gives an average of the percent complete each day. How can I modify my % Bakery Oven Inspections Complete calculation to show the average percent complete each day?
 
1 ACCEPTED SOLUTION
A_Scott
Helper I
Helper I

I was able to figure out the calculation using AverageX and Values.

View solution in original post

8 REPLIES 8
A_Scott
Helper I
Helper I

I was able to figure out the calculation using AverageX and Values.

Anonymous
Not applicable

Hi @A_Scott ,

 

Is it possible to provide relevant test data about your data model so that I can easily locate your error and provide relevant solutions.

 

Best regards,

Adamk Kong

Here are examples of my resouces. 

 

This is my primary resouce. In my star scema, everything else branches off from this list of equipment. It is my true list of equipment in my locations.

Division-Store/Equipment Product Type Descr/Unique Equipment ID
011-00695OVEN011-00695-3298377-OVEN
011-00696OVEN011-00696-3269665-OVEN
011-00697OVEN011-00697-3255180-OVEN
011-00697OVEN011-00697-3255181-OVEN
011-00699OVEN011-00699-3272815-OVEN
011-00703OVEN011-00703-3303547-OVEN
011-00703OVEN011-00703-3303548-OVEN
011-00730OVEN011-00730-3269920-OVEN
011-00730OVEN011-00730-3269921-OVEN
011-00867OVEN011-00867-3280965-OVEN
011-00979OVEN011-00979-3285966-OVEN

This is a list of the inspections perfromed in several locations. The employee manually enters in the unique equipment id. They don't always get this right and I am only counting the completed inspections that have accurate unique equipment numbers. They are also required to perform 1 inpsection everyday. So, if a location completes 7 inspections in a single day, and none on the others they will only get credit for 100% complete for the one day and 0% the other 6. which would make them only 14.29% complete.

OVEN_INSPECTION_ID/Division-Store/Equipment Type/Unique Bakery Oven ID/LOG_DATE/INSPECTION_FAILED
15082011-00703Oven011-00703-3303548-OVEN1/1/2024N
15083011-00703Oven011-00703-3303547-OVEN1/1/2024N
15084021-00410Oven021-00410-4427529-OVEN1/1/2024N
15086011-00695Oven011-00695-3298378-OVEN1/1/2024N
15089011-00695Oven011-00695-3298378-OVEN1/1/2024N
15090011-00695Oven011-00695-123456-OVEN1/1/2024N
15091016-00805Oven016-00805-3430511-OVEN1/1/2024N
15092016-00805Oven016-00805-3430512-OVEN1/1/2024N
15095024-00744Oven024-00744-4491593-OVEN1/1/2024N
15096016-00623Oven016-00623-3449772-OVEN1/1/2024N
15097016-00623Oven016-00623-3449773-OVEN1/1/2024N
15098011-00671Oven011-00671-3251901-OVEN1/1/2024N
15099014-00359Oven014-00359-4134000-OVEN1/1/2024N
15100014-00359Oven014-00359-4133999-OVEN1/1/2024N
15101011-00439Oven011-00439-3285829-OVEN1/1/2024N
15104016-00920Oven016-00920-3450080-OVEN1/1/2024N
15105016-00920Oven016-00920-3450079-OVEN1/1/2024N
15109011-00485Oven011-00485-3277319-OVEN1/1/2024N
15113011-00016Oven011-00016-3303275-OVEN1/1/2024N
15117011-00413Oven011-00413-3274902-OVEN1/1/2024Y
15118011-00413Oven011-00413-3274904-OVEN1/1/2024N
15123034-00744Oven034-00744-3313724-OVEN1/1/2024N
15124034-00744Oven034-00744-3313763-OVEN1/1/2024N
15126615-00018Oven615-00018-4016498-OVEN1/1/2024N
15129615-00056Oven615-00056-4204898-OVEN1/1/2024N
15131018-00743Oven018-00743-8023210-OVEN1/1/2024N
15132018-00743Oven018-00743-8023209-OVEN1/1/2024N

.What I'm looking for I guess is an average per day

johnt75
Super User
Super User

Try 

% Bakery Oven Inspections Complete =
VAR OvenCount = [Oven Count]
RETURN
    IF (
        OvenCount = 0,
        "N/A",
        VAR MaxDate =
            MAX ( 'Date'[Date] )
        VAR Result =
            AVERAGEX (
                VALUES ( 'Open Locations'[Division-Store] ),
                CALCULATE (
                    AVERAGEX (
                        DATESBETWEEN ( 'Date'[Date], MaxDate - 6, MaxDate ),
                        MIN ( 1, [Complete Bakery Oven Inspections] / OvenCount )
                    )
                )
            )
        RETURN
            Result
    )

I removed the IF ISINSCOPE because it was unneeded. If there is a single store in the filter context then VALUES will only return that store.

I was using inscope because my grand total without it was not the same as the sum of the rows. Will this Values calculation ensure all the sum of the rows will equal what Power BI tells me the grand total should be for that column?

This still showed a location that did not have an inspection everyday for the last 7 days as being 100%.

Their inspection count:

Date # of Inspections
15-Nov2
16-Nov 
17-Nov 
18-Nov 
19-Nov2
20-Nov2
21-Nov2
Total8

 

If the Inspections are as follows:

Date - # Complete - Max % Complete

11/15 - 2 - 100%

11/16 - 0 - 0%

11/17 - 0 - 0%

11/18 - 0 - 0%

11/19 - 2 - 100%

11/20 - 2 - 100%

11/21 - 2 - 100%

% Complete for those 7 days would be the average of all equaling 57.14%?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.