Hi,
This is the case of lookup, for this, try like as shown below
Here I have created 2 SP list,
1. One Source List 1 , which has some columns along with one column as lookup column which reference other sp list.
Here PID is the lookup column to other SP List.
Lookup column is like as shown below
Now for each row in Source List 1, i want to get finance value and attach to it and convert to csv object
see below flow design on how i have acheived it.
1. Use initialize variable to initialize an array like below
2. Use get items to get items in source list 1
3. Loop through each item of source list 1 using apply to each as shown below
Next 2 steps will be in loop
3.1- use get items on lookup list 1 using odata filter query which helps to filter the lookup column value on the other list as shown below
3.2- use append to array variable to append the object we need for creating csv data something like as shown below
Expression used here-
first(outputs('Get_items_2')?['body/value'])?['Finance']
Now we have added an object which contains all attributes which final csv file should have. Now as part of next steps, we will use create csv table action to convert the array variable to csv formatted file which would be done outside loop.
Hope it helps !