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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Calculate for every different product

Hey!

 

I wanna calculate the RunTime of a device the last 24 hours, but I am having problem to make it filter just its devices as:

 

Device         Index           TotalRunTime (h)             (NewRunLoad)

A                    1                       2046                                 6

B                    2                       3                                       3 

A                    3                       2040                                 0 

B                    4                       0                                       0

 

(There are even more data)

 I want a column that calculates the different since the last index OF ITS OWN DEVICE.  For example for device A 2046-2040 = 6, I tried a couple of different functions but I cant really figure it out. 

 

 

NewRunLoad =
var ett = LOOKUPVALUE('Data'[RunLoad_h], Data[Index], Data[Index])
var tva = LOOKUPVALUE('Data'[RunLoad_h],'Data'[Index], Data[Index]-1)
return
CALCULATE(ett-tva, ALLEXCEPT(Data,Data[Device])

 

 

Kind regards

1 ACCEPTED SOLUTION
LivioLanzo
Solution Sage
Solution Sage

@Anonymous

 

I think this should do what you want:

 

 

Column =
VAR minIndx =
    CALCULATE (
        MIN ( Table1[Index] ),
        ALLEXCEPT ( Table1, Table1[Device] ),
        Table1[Index] > EARLIER ( Table1[Index] )
    )
RETURN
    IF (
        ISBLANK ( minIndx ),
        BLANK (),
        Table1[TotalRunTime (h)]
            - CALCULATE (
                SUM ( Table1[TotalRunTime (h)] ),
                Table1[Index] = minIndx,
                ALL ( Table1 )
            )
    )

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

View solution in original post

1 REPLY 1
LivioLanzo
Solution Sage
Solution Sage

@Anonymous

 

I think this should do what you want:

 

 

Column =
VAR minIndx =
    CALCULATE (
        MIN ( Table1[Index] ),
        ALLEXCEPT ( Table1, Table1[Device] ),
        Table1[Index] > EARLIER ( Table1[Index] )
    )
RETURN
    IF (
        ISBLANK ( minIndx ),
        BLANK (),
        Table1[TotalRunTime (h)]
            - CALCULATE (
                SUM ( Table1[TotalRunTime (h)] ),
                Table1[Index] = minIndx,
                ALL ( Table1 )
            )
    )

 


 


Did I answer your question correctly? Mark my answer as a solution!


Proud to be a Datanaut!  

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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