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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
D-Meak
Regular Visitor

Calculate a moving percentage over time based on last items not last time period

Hello,

 

I'm trying to produce a graph showing a moving percentage based on the last number of items, as when I produced a graph based on the last period of time it had some very sharp edges (due to low production quantity over time)

 

The desired output graph is in the style as follows.  So for a specific day it takes the last 10 items produced, counts how many items had a Defect (from the Defect column) and divides by the last 10 items to give a percentage with the defect

DMeak_1-1675094588995.png

 

The data is as follows

DMeak_0-1675094466393.png

 

I have a relationship between my Calendar and the Inspection Date column.

Defect Rate Last X = 
VAR NoItems = 10

RETURN
DIVIDE(
    CALCULATE(
        COUNTX(
            FILTER(
                ALL('Calendar'),
                [Date] <= MAX('Calendar'[Date])
            ),
            COUNTX(
                FILTER(
                    TOPN (NoItems, ALL('Inspections'[Defect],'Inspections'[Inspection Date]), Inspections[Inspection Date], DESC),
                    'Inspections'[Defect] = "Yes"
                ),
                'Inspections'[Defect])
        )
    ),
NoItems
)

Currently the output is as follows:

DMeak_3-1675095393953.png

 

Thank you

0 REPLIES 0

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.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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