Woohoo!! This is awesome. I was trying to figure out a way to put multiple columns side by side in a report and adapted the MOD() suggestion (thanks, @Aleksi). I tried using row numbers like the example, but that only worked for 2 columns and those columns were uneven if I hadn’t selected the same number of odd and even rows. Instead, I created virtual columns in the child table (where reports are generated), because it allows for any number of columns and is consistent no matter how many/which Ref items are selected. The formula could be used in the report template “Start:” expression instead so it only runs when a report and doesn’t constantly affect app performance. I haven’t used any sorting, but you could add that to the VC column formula or in the report template depending on your application. In case it’s helpful to anyone else:
NOTE: This only works if the keys in your parent table all have the same length.
Parent Table: inventory; PK [inventoryID] = “inventory”&UNIQUEID()
Child Table: inventoryPrintLabels; Ref column [inventoryIDs] is EnumList with base type Ref so you can select all the inventory items you want to print labels for
Create a Virtual Column in the child table for each column (e.g. [_inventoryIDsCol1],[_inventoryIDsCol2], [_inventoryIDsCol3])
Set the element Type to Ref of the parent table so you can use the regular report expressions for child records
The app formula in each VC column:
Copy the app formula into each VC column, updating the Col# as appropriate (1,2,3…)
In the report template create a table with the number of columns you want and fill each column with the usual report expressions. Only the start expression changes in each cell: <Start:_inventoryIDsCol1>,<Start:_inventoryIDsCol2>,etc
APP FORMULA EXPLANATION
>> Select the Ref IDs from the parent table
>> Where multiple conditions are true
>> 1. The Key is one of those referenced in the child table Ref column
>> 2A. FIND(): Get the position of the parent row in the list of Refs (based on number of characters).
>> 2B. -1: Subtract 1 to normalise number.
>> 2C. /len() +3: Divide by the the length (# of characters) of the keys +3 (all keys must all be the same length). +3 is the number of characters automatically added in AppSheet in the list (" , "): ID1 , ID2 , ID3 , …
>> 2D. MOD(): Divide the position you just calculated (steps 2A,2B,2C) by the total number of columns you’re trying to make to get the remainder.
>>+1: Add 1 to get the column #.
>> 2E. The column # you just calculated equals the column # for this VC.