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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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!

1 ACCEPTED SOLUTION

@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
1.PNG
 




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

Proud to be a Super User!




View solution in original post

5 REPLIES 5
ryan_mayu
Super User
Super User

@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])

1.PNG





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

Proud to be a Super User!




Anonymous
Not applicable

I just tried your query but gotquery.png an empty column.

 

@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
1.PNG
 




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

Proud to be a Super User!




Anonymous
Not applicable

Thank you so much, I just missed renaming that too.

Could you please also explain the query? would be really helpful to understand.

@Anonymous 

find the last success record, then add up all time from one after last success record until the current record.





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

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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