The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Measure ShiftSum_First wasn't returning the correct result, when digging into I found that a variable within the measure was returning some unexpected results. See image below, Work Center 'A' in this case works as expected - it gets the sum of Seconds that would have resulted during the First Shift (7am to 3pm) while the machine is 'Running', adds up correctly to 26,661 seconds. Work Center B in this case operates correctly at row level, but sum it becomes -146,326? Why isn't it 26,474?
I've provided two measures below, ShiftStrt & ShiftEnd are referenced in my ShiftSum measure. ShiftStrt and ShiftEnd are exactly the same except one references column 'StartDate' the other references 'EndDate'.
There's only one outside filter influence on Start Date, shown below.
Hi @Anonymous ,
You can create a measure:
Place it in the table and compare with [ShiftSum_First], and find whether total is displayed correctly:
Measure=
VAR __table = SUMMARIZE(MachineBoxInfo, MachineBoxInfo[Startdate] ,"__value", [ShiftSum_First])
RETURN
IF(HASONEVALUE(MachineBoxInfo[Startdate]), [ShiftSum_First],SUMX(__table,[__value]))
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
@Anonymous , we need force a row context from visual example
var SecsCarryOver = CALCULATE(SUMX(values(MachineBoxInfo[workcenter]) ,
IF([ShiftStrt]=3,Datediff(RowStartTime,MachineBoxInfo[Enddate],Second),
IF([ShiftStrt]=1,DATEDIFF(MachineBoxInfo[Startdate],RowEndTime,second),blank()))), FILTER(MachineBoxInfo,AND(OR(AND([ShiftStrt]=1,[ShiftEnd]=2),AND([ShiftStrt]=3,[ShiftEnd]=1)),MachineBoxInfo[statedesc]="Running")))
refer if needed
var SecsCarryOver = CALCULATE(SUMX(values(MachineBoxInfo[workcenter]) ,
IF([ShiftStrt]=3,Datediff(RowStartTime,MachineBoxInfo[Enddate],Second),
IF([ShiftStrt]=1,DATEDIFF(MachineBoxInfo[Startdate],RowEndTime,second),blank()))), FILTER(MachineBoxInfo,AND(OR(AND([ShiftStrt]=1,[ShiftEnd]=2),AND([ShiftStrt]=3,[ShiftEnd]=1)),MachineBoxInfo[statedesc]="Running")))
@amitchandak Thank you for your response, unfortunately that didn't work. When using the Values on the WorkCenter I cannot simply refer to the StartDate and EndDate columns, as they aren't in the input table. I used max() to refer to them, and it worked at the row level but totals didn't come through correctly. I know I can add another measure to handle this with HASONEVALUE on the total row, but I'd like to accomplish it in one measure if possible.