cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Error in my code?

Hey!

 

Can anyone see what gets wrong with my DAX formula?

 

I write following: 

 
NewRunLoad =
 
VAR minIndx =
      CALCULATE (
           MAX ( Data[Index] ),
                 ALLEXCEPT ( Data, Data[Device] ),
                         Data[Index] > EARLIER (Data[Index] )
 )
 
RETURN
 
IF (
ISBLANK ( minIndx ),
BLANK (),
Data[TimeLoaded_LC]
         - CALCULATE (
             SUM ( Data[TimeLoaded_LC] ),
                          Data[Index] = minIndx,
              ALLEXCEPT(Data,Data[Device] )
  )
)

 

 

 

This is what TimeLoaded_LC is, and this is what NewRunLadoad gets:

 

Capture.PNGCapture.PNG

 

I want it to take the current value, - previous value. as 988 - 987.9 = 0.1 and this value to be in NewRunLoad. 

 

Thanks!

 

Kind regards

Agnes

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft
Microsoft

Re: Error in my code?

Hi @Anonymous,

 

Please refer to below DAX formula:

NewRunLoad =
IF (
    CALCULATE (
        MAX ( Data[Index] ),
        FILTER ( ALLEXCEPT ( Data, Data[Device] ), [Index] < EARLIER ( Data[Index] ) )
    )
        = BLANK (),
    BLANK (),
    Data[TimeLoaded_LC]
        - CALCULATE (
            SUM ( Data[TimeLoaded_LC] ),
            FILTER (
                ALLEXCEPT ( Data, Data[Device] ),
                [Index]
                    = EARLIER ( Data[Index] ) - 1
            )
        )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Super User IV
Super User IV

Re: Error in my code?

Is this a measure? 

 

Seems like your > sign in your minIndx VAR should be a < sign.


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!
Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Microsoft
Microsoft

Re: Error in my code?

Hi @Anonymous,

 

Please refer to below DAX formula:

NewRunLoad =
IF (
    CALCULATE (
        MAX ( Data[Index] ),
        FILTER ( ALLEXCEPT ( Data, Data[Device] ), [Index] < EARLIER ( Data[Index] ) )
    )
        = BLANK (),
    BLANK (),
    Data[TimeLoaded_LC]
        - CALCULATE (
            SUM ( Data[TimeLoaded_LC] ),
            FILTER (
                ALLEXCEPT ( Data, Data[Device] ),
                [Index]
                    = EARLIER ( Data[Index] ) - 1
            )
        )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

April 2020 Community Highlights

April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors