Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Calculation of process_time values based on success column using dax calculated columns

Hello everyone,

I am new to Power BI and need help to create a new calculated column with DAX. I have this below-mentioned table where status or success columns represent process is finished successfully or not. (1 or F means finished successfully otherwise not), process_time_in_minutes column represents the duration of the process.

 

idstatussuccessprocess_time_in_minutes
1F180
2L070
3L030
4F160
5L050
6F134

 

I need a new table like the below one. I want to get total values for a successful process, so if the process has failed then process duration should be kept adding until it gets successful

What I actually want is if the process finished successfully means success = 1 then process time is the same for the next column, otherwise, if it is failed then it should add all previous values till success =1, for first failed process it will be same value as there is no previous failed, but for next ones, it should be kept adding until process finished successfully. 

 

idstatussuccessprocess_time_in_minutesupdated_process_time_in_minutes
1F18080
2L07070
3L030100
4F160160
5L05050
6F13484

 

Please help me to write a DAX query for this. Thanks!

  • Anonymous 

    pls try this

    Column =
    VAR _LAST=MAXX(FILTER(hk_job,hk_job[id]<EARLIER(hk_job[id])&&hk_job[status]="F"),hk_job[id])
    return sumx(FILTER(hk_job,hk_job[id]>_LAST&&hk_job[id]<=EARLIER(hk_job[id])),hk_job[process_time])
     
    i have highlighted the difference between my DAX and yours.
    pls update your DAX
     

5 Replies

  • Anonymous 

    you can try to create a column

    Column = 
    VAR _LAST=maxx(FILTER('Table','Table'[id]<EARLIER('Table'[id])&&'Table'[status]="F"),'Table'[id])
    return sumx(FILTER('Table','Table'[id]>_LAST&&'Table'[id]<=EARLIER('Table'[id])),'Table'[process_time_in_minutes])

    • Anonymous's avatar
      Anonymous
      Not applicable

      I just tried your query but got an empty column.

       

      • ryan_mayu's avatar
        ryan_mayu
        Icon for Super User rankSuper User

        Anonymous 

        pls try this

        Column =
        VAR _LAST=MAXX(FILTER(hk_job,hk_job[id]<EARLIER(hk_job[id])&&hk_job[status]="F"),hk_job[id])
        return sumx(FILTER(hk_job,hk_job[id]>_LAST&&hk_job[id]<=EARLIER(hk_job[id])),hk_job[process_time])
         
        i have highlighted the difference between my DAX and yours.
        pls update your DAX