Forum Discussion
Unrelated Tables
Hi Anonymous. Thanks for your reply. You have used MAX ItemTransaction[ScheduleID] = MAX(BreakTime[ScheduleID]) in this statement. Does that mean it will always pick the first row? Because somehow scheduleID will be the same for the selected rows in BreakTime table.
Sorry, I don't quite understand what your expression does. Do you mind explaining?
I gave a sample condition only. But, in actual I've 4 conditions. Can I fit in them in the same measure?
//If BreakTime is out of TrxTime, No BreakTime
if (vBreakTimeEnd <= pStartTime) { break; }
if (vBreakTimeStart >= pEndTime) { break; }
//If TrxTime is between BreakTime
if (vBreakTimeStart <= pStartTime && vBreakTimeEnd >= pEndTime)
vTotalBreakTime += (pEndTime - pStartTime).TotalSeconds;
//if BreakTime is between TrxTime
else if (vBreakTimeStart >= pStartTime && vBreakTimeEnd <= pEndTime)
vTotalBreakTime += (vBreakTimeEnd - vBreakTimeStart).TotalSeconds;
//if BreakTime starts before TrxTime
else if (vBreakTimeStart <= pStartTime && (vBreakTimeEnd >= pStartTime && vBreakTimeEnd <= pEndTime))
vTotalBreakTime += (vBreakTimeEnd - pStartTime).TotalSeconds;
//if BreakTime starts after TrxStartTime
else if (vBreakTimeEnd >= pEndTime && (vBreakTimeStart >= pStartTime && vBreakTimeStart <= pEndTime))
vTotalBreakTime += (pEndTime - vBreakTimeStart).TotalSeconds;
Hi tracy,
>>You have used MAX ItemTransaction[ScheduleID] = MAX(BreakTime[ScheduleID]) in this statement. Does that mean it will always pick the first row?
It will get the current “scheduleID”, for more detail information about measure and calculate column, you can refer to below link:
column vs measure
According to your conditions, you want to get the “middle range” of tables and get the total minute of these records, right?
You can try to use below formula to see if it works on your side.
Measure:
condition total = var currBreakStart=MAX(BreakTime[BreakStartTime]) var currBreakEnd=MAX(BreakTime[BreakEndTime]) var currScheduleID=LASTNONBLANK(BreakTime[ScheduleID],BreakTime[ScheduleID]) return SUMX(FILTER(ALL(ItemTransaction), ItemTransaction[ScheduleID]=currScheduleID&&AND(ItemTransaction[StartTime]<currBreakEnd,ItemTransaction[EndTime]>currBreakStart)), DATEDIFF(MAX(ItemTransaction[StartTime],currBreakStart),MIN(ItemTransaction[EndTime],currBreakEnd),SECOND))
If above is not help, please feel free to let me know.
Regards,
Xiaoxin Sheng
- tracy9 years agoFrequent Visitor
Hi Anonymous, I created a measure as you had given. But, the calculated column using your previous expression (TotalSecond = IF([Condition Total]=BLANK(),0,[Condition Total])) throws this error:
A circular dependency was detected: BreakTime[Column], BreakTime[TotalSecond], BreakTime[Column]Also, I actually want to update the total seconds in ItemTransaction table like below. I want the calculated break time beside each employee's record. Is this possible?
***Very importantly, can you advise me if we can put the other conditions in the same measure pleaseee?- Anonymous9 years agoNot applicable
- tracy9 years agoFrequent Visitor
Hi Anonymous, I'm just enlightening you that I want the break time total seconds to be put into ItemTransaction table as per what I've stated above. Is that possible or not? Please advise.
And FYI, when I tested your measure at my end, my result is different from yours. See here.