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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Cumulative Repair Rates

I have reviewed every post I can find on the topic, however, I can't find one that matches my criteria. What I want to do is chart a product repair rate per month and cumulative overtime. I've tried to create a measure and a separate table that does this however, I cannot get either to work. I've included screen caps for what I want and included a link for Excel Sample Data

 

What I want

Screen Shot 2022-03-23 at 12.45.02 PM.png

What I get

Screen Shot 2022-03-23 at 12.49.19 PM.png

 

DAX Measure

 

Cumulative Repair Rate = 
VAR Cumulative_Repairs = 
    COUNTROWS(
        FILTER('Project-1 Log',
            FIND("R",'Project-1 Log'[Suffix],,0
            ) > 0
        )
    )+
    CALCULATE(
        SUM('Project-2 Log'[Repairs]),
            FILTER(
                ALLSELECTED('Project-2 Log'),
                'Project-2 Log'[Month] <= MAX('Project-2 Log'[Month])
        )
    )

VAR Cumulative_Welds = 
    CALCULATE(
        DISTINCTCOUNT('Project-1 Log'[IDNo]),
        FILTER(
            ALLSELECTED('Project-1 Log'),
            'Project-1 Log'[DateCompleted] <= MAX('Project-1 Log'[DateCompleted])
        )
    )+
    CALCULATE(
        SUM('Project-2 Log'[QtyID]),
        FILTER(
            ALLSELECTED('Project-2 Log'),
            'Project-2 Log'[Month] <= MAX('Project-2 Log'[Month])
        )
    )
RETURN

DIVIDE(Cumulative_Repairs,Cumulative_Welds,0)

 

 

Model Mockup

(the actual model is quite large so I extracted the relevant parts that affect the measure, both are Many-to-1 relationships)

Screen Shot 2022-03-23 at 12.35.43 PM.png

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

I think what's going on is that you're using 'Project-2 Log'[Month] as the chart's x-axis but this isn't related to 'Project-1 Log'[DateCompleted]. This means that the first component of your Cumulative_Welds variable is just a constant value DISTINCTCOUNT ( 'Project-1 Log'[IDNo] ).

 

The best solution is to create a date dimension table with relationships to both project tables and use that for your chart axis and inside your measure instead of the date columns of the project table.

Cumulative Repair Rate =
VAR CurrDate =  MAX ( dimDate[Date] )
VAR Cumulative_Repairs =
    COUNTROWS (
        FILTER (
            'Project-1 Log',
            FIND ( "R", 'Project-1 Log'[Suffix],, 0 ) > 0
        )
    ) +
    CALCULATE (
         SUM ( 'Project-2 Log'[Repairs] ),
         dimDate[Date] <= CurrDate
    )
VAR Cumulative_Welds =
    CALCULATE (
        DISTINCTCOUNT ( 'Project-1 Log'[IDNo] ),
        dimDate[Date] <= CurrDate
    ) +
    CALCULATE (
        SUM ( 'Project-2 Log'[QtyID] ),
        dimDate[Date] <= CurrDate
    )
RETURN
    DIVIDE ( Cumulative_Repairs, Cumulative_Welds, 0 )

View solution in original post

1 REPLY 1
AlexisOlson
Super User
Super User

I think what's going on is that you're using 'Project-2 Log'[Month] as the chart's x-axis but this isn't related to 'Project-1 Log'[DateCompleted]. This means that the first component of your Cumulative_Welds variable is just a constant value DISTINCTCOUNT ( 'Project-1 Log'[IDNo] ).

 

The best solution is to create a date dimension table with relationships to both project tables and use that for your chart axis and inside your measure instead of the date columns of the project table.

Cumulative Repair Rate =
VAR CurrDate =  MAX ( dimDate[Date] )
VAR Cumulative_Repairs =
    COUNTROWS (
        FILTER (
            'Project-1 Log',
            FIND ( "R", 'Project-1 Log'[Suffix],, 0 ) > 0
        )
    ) +
    CALCULATE (
         SUM ( 'Project-2 Log'[Repairs] ),
         dimDate[Date] <= CurrDate
    )
VAR Cumulative_Welds =
    CALCULATE (
        DISTINCTCOUNT ( 'Project-1 Log'[IDNo] ),
        dimDate[Date] <= CurrDate
    ) +
    CALCULATE (
        SUM ( 'Project-2 Log'[QtyID] ),
        dimDate[Date] <= CurrDate
    )
RETURN
    DIVIDE ( Cumulative_Repairs, Cumulative_Welds, 0 )

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.