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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
zombieug
Helper I
Helper I

Calculate Column based on different Values

 

Hi forum Smiley Happy

 

I would appreciate your help on the following matter:

down below you can see an example table. I would like to calculate the column Lifecycle based on:

partnumber & the date difference between the applied action install.

 

2018-01-26_12h18_11.png

 

 

I hope the example table explains better what I am trying to do (calculate lifecycle in days --> for each partnumber if install dates are available - lifecycle intervall is last install date subtracted by the the install date before).

 

I am kind of new to Power BI and DAX so I would really appreciate it if somebody could help me on that matter.

 

If the example I am showing is not doable in Power BI or you need any further information please let me know.Smiley Very Happy

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@zombieug

 

Try this Calculated Column

 

LifeCycle =
VAR CurrentDate = TableName[Date]
VAR PreviousDate =
    CALCULATE (
        MAX ( TableName[Date] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[PartNumber] ),
            TableName[Action] = "Install"
                && TableName[Date] < CurrentDate
        )
    )
RETURN
    IF (
        NOT ( ISBLANK ( PreviousDate ) )
            && TableName[Action] = "Install",
        DATEDIFF ( PreviousDate, CurrentDate, DAY )
    )

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@zombieug

 

Try this Calculated Column

 

LifeCycle =
VAR CurrentDate = TableName[Date]
VAR PreviousDate =
    CALCULATE (
        MAX ( TableName[Date] ),
        FILTER (
            ALLEXCEPT ( TableName, TableName[PartNumber] ),
            TableName[Action] = "Install"
                && TableName[Date] < CurrentDate
        )
    )
RETURN
    IF (
        NOT ( ISBLANK ( PreviousDate ) )
            && TableName[Action] = "Install",
        DATEDIFF ( PreviousDate, CurrentDate, DAY )
    )

@Zubair_Muhammad

 

Amazing. Thanks for helping out that fast.

Helpful resources

Announcements
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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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