Hi. I've tables that are not related as you can see in the picture below (no unique values in either one to create relationship). But, I need to pick a row from ItemTransaction table and check upon BreakTime table to find under which breaktime this transaction time (StartTime & EndTime) falls into based on the ScheduleID. Is there a way to do this in Power BI desktop? Since, the tables are not connected, my collegue used Visual Studio coding to compute the logic. Somehow, I'm trying to apply this logic with Power BI. Is that possible? Please help.
foreach (DataRow dr in drArray) { //Multiple BreakTime might happen in a single TrxTime DateTime vBreakTimeStart = Convert.ToDateTime(dr["BreakTimeStart"]); DateTime vBreakTimeEnd = Convert.ToDateTime(dr["BreakTimeEnd"]); //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; }