Forum Discussion
Anonymous
7 years agoNot applicable
Loop through rows under condition and count difference
I have timestamps under each other in one column, have detected the rows where full time period starts and ends thanks to indexing. Now, how do I lopp through the column and sum the whole time in bet...
- 7 years ago
Hi Anonymous
Based on my simplified sample data, the measure could get the datediff between the start and end time.
Measure = var last_start=CALCULATE(MAX('Time'[time]),FILTER(ALL('Time'),'Time'[time]<=MAX('Time'[time])&&'Time'[end/start]="start")) return IF(MAX('Time'[end/start])="end",DATEDIFF(last_start,MAX('Time'[time]),HOUR))If you need column,you may try below dax.
Column = var last_start=CALCULATE(MAX('Time'[time]),FILTER('Time','Time'[time]<=EARLIER('Time'[time])&&'Time'[end/start]="start")) return IF('Time'[end/start]="end",DATEDIFF(last_start,'Time'[time],HOUR))Regards,
- Anonymous7 years ago
The measure you have posted did not work for me, but I've used a different approach - adding new index column to the table and then merging the table on itself.
Anonymous
7 years agoNot applicable
Because the column looks like this, with more specified periods for one id. v-cherch-msft More sample rows
Anonymous
7 years agoNot applicable
The measure you've provided just does not do the job. I've separated the times into two columns and just need do substract them from each other. If there is end time provided, substract start time from it otherwise from now time substract start time. As in pictures provided.
snippetmeasure