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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
szub
Helper III
Helper III

Need to calculate number of days until first failure from unit sale date

Hello,

 

I have two dates that I need to determine the number of days between in a Sales Table and a Claim Table by serial number.  Below is sample data for a Sales and Claim table.  What I need to find is the number of days between the Sale Date on the Sales table and the FIRST Failure Date on the Claim Table if the Claim Type is Standard or Extended.

 

Sales Table

Serial #Sale Date
Serial11/2/2018
Serial22/14/2019
Serial39/24/2018
Serial412/16/2017
Serial53/1/2017
Serial64/12/2019
Serial711/18/2019


Claim Table

Serial #Claim #Claim TypeFailure Date
Serial1Claim1Install2/1/2018
Serial1Claim2Standard1/13/2019
Serial2Claim3Startup3/14/2019
Serial3Claim4Standard3/6/2019
Serial3Claim5Standard10/1/2019
Serial4Claim6Startup3/5/2017
Serial4Claim7Standard2/11/2018
Serial5Claim8Standard2/14/2019
Serial5Claim9Extended7/6/2019

 

Appreciate any help!

Thanks

1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @szub 

try a measure

 

Measure = 
var _firstFailure = calculate(min('Claim Table'[Failure Date]), OR('Claim Table'[Claim Type]="Standard",'Claim Table'[Claim Type]="Extended"))
return 
datediff(selectedvalue('Sales Table'[Sale Date]),_firstFailure,DAY)

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @szub

You can create one measure as below:

Need to calculate number of days until first failure from unit sale date.JPG

bdays =

VAR a =

    MAX ( 'Claim'[Serial #] )

VAR b =

    DATEDIFF (

        CALCULATE (

            MAX ( 'Sales'[Sale Date] ),

            FILTER ( 'Sales', 'Sales'[Serial #] = a )

        ),

        CALCULATE (

            MIN ( 'Claim'[Failure Date] ),

            FILTER (

                'Claim',

                ( 'Claim'[Claim Type] = "Standard"

                    || 'Claim'[Claim Type] = "Extended" )

                    && 'Claim'[Serial #] = a

            )

        ),

        DAY

    )

RETURN

    b

 

Best Regards

Rena

az38
Community Champion
Community Champion

Hi @szub 

try a measure

 

Measure = 
var _firstFailure = calculate(min('Claim Table'[Failure Date]), OR('Claim Table'[Claim Type]="Standard",'Claim Table'[Claim Type]="Extended"))
return 
datediff(selectedvalue('Sales Table'[Sale Date]),_firstFailure,DAY)

 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

@az38 That worked!  Thanks

Greg_Deckler
Community Champion
Community Champion

So something like:

 

Column = MINX(RELATEDTABLE('Claim Table'),[Failure Date])


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.