Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Please help me on calculate function

Hi,

I need to implement the below logic in DAX :

If (LW_SEND_END_DATE_TIME is not NULL) and (LW_SEND_START_DATE_TIME is not NULL) and DOCUMENT_ERROR_STEP not Like "%SEND%" ) then AVG (LW_SEND_END_DATE_TIME - LW_SEND_START_DATE_TIME)

 

and I am very new at Power BI, can anyone help me on this?

3 Replies

  • AlB's avatar
    AlB
    Community Champion

    Hi Anonymous,

    For an accurate response you need to show the tables in your data model involved in the calculation and explain what each element in your formula is. Without that information, i would venture this:

     

    IF(NOT ISBLANK(LW_SEND_END_DATE_TIME) && NOT ISBLANK(LW_SEND_START_DATE_TIME) && DOCUMENT_ERROR_STEP<>"%SEND%", AVERAGE (LW_SEND_END_DATE_TIME - LW_SEND_START_DATE_TIME))

    I'm not clear on the red part because I need the explanation mentioned above.

     

    Please read through these posting tips (particularly the bits in red). By following them, you will increase the probability of getting your questions answered quickly and you will make things much easier for people trying to help.

     

     

  • mussaenda's avatar
    mussaenda
    Community Champion
    FILTER = 

    VAR ENDSTART = LW_SEND_END_DATE_TIME - LW_SEND_START_DATE_TIME RETURN IF (LW_SEND_END_DATE_TIME <> BLANK() && LW_SEND_START_DATE_TIME <> BLANK() && DOCUMENT_ERROR_STEP <> "%SEND%" , CALCULATE( AVERAGE(ENDSTART)))
     

    Maybe something like this?