I have an Action that “adds an new row to another table using data from this row”.
I am trying to tally data from a Timesheet table using the below expression, but it is not aggregating the data because it just displays “0”. SUM( SELECT(Timesheet[Total Hours], ([_THISROW].[WorkorderID] = [WorkorderID]) ))
Any suggestions on how to get this data to do the proper math?
It is difficult to assist as no data is provided from the select nor the datatype.
What is [Total Hours] data type ? Number or Datetime or Hours ?
To debug go into the expression assistant and just do the SELECT and then evaluate the select and see what data is being returned ? It should be LIST().
I have tried it as various data types, Number, Duration, Text.
I did try and debug it by entering the expression in the ValidIF box. I tested every column to see if i can pull the data and for some reason I am able to pull data from every single column except the [Total Hours] column. I will say that the Timesheet column [Total Hours] has the hours in this format, 000:00:00. Could that be the cause?
Yes the data format is key. Note that hours in time format may never get greater than 23 so one cannot add them as say 12:00:00 + 12:00:00 + 12:00:00 = 1 day + 12:00:00
So what you want to do is extract the hours part only, which by default is in NUMBER format.
Maybe create a virtual column HOURSNUM = HOUR(TIME(Timesheet[Total Hours]) - TIME(“00:00:00”)) and this should return hours only in number format.
I actually tested the above method and it worked fine.
You can use SUM() with Duration-type values, so your SUM(SELECT(...)) should work fine so long as the SELECT() expression is producing a list of Duration values. Likewise, the column receiving the result of the SUM(SELECT(...)) should be the Duration type to correctly display the result.
Ok, I was able to get everything to work. This is a bit strange but all I had to do was add “[_THISROW]” in front of [WorkorderID] inside the action used to create the report (see image).
About the only thing that looks a bit off is the fact that it is no longer filling the WorkorderID field with anything, just blank, but everything is calculating correctly. (see image)
I have had this same blank column issue before and I had to make the spreadsheet column type format and APPSHEET column type format different. When I made the spreadsheet type Plain Text it populated the column?
Why this works I am not sure but I head bashed and found it worked fine.