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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
v-yiruan-msft
Community Support
Community Support

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

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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
Super User
Super User

So something like:

 

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

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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