'Power Automate - get values when column headers in Column A

I've been googling away on this, and struggling to find anyone who has faced this issue previously and come up with a way to resolve it. I'm trying to pull the value from B7 which is 14/04/2022.

enter image description here

Currently I'm getting this back, and the problem is the column header is 12/04/2022 and not [Enter End Date] so I have a consistent header to reference later on in the flow.

{
  "@odata.context": "",
  "value": [
    {
      "@odata.etag": "",
      "ItemInternalId": "",
      "Enter Start Date": "Enter End Date",
      "12/04/2022": " 14/04/2022"
    }
  ]

My flow is looking like this:

enter image description here

enter image description here

enter image description here



Solution 1:[1]

If I were you, I'd use Office Scripts as it can be tailored and controlled much easier than the built in functions that return data from tables.

https://support.microsoft.com/en-us/office/introduction-to-office-scripts-in-excel-9fbe283d-adb8-4f13-a75b-a81c6baf163a

I created a script called Extract Parameters with the following code ...

function main(workbook: ExcelScript.Workbook)
{
  let worksheet = workbook.getWorksheet("Parameters");

  return {
    "Enter Start Date": worksheet.getRange("B6").getText(),
    "Enter End Date": worksheet.getRange("B7").getText(),
  };
}

... and then invoked that script using the Run script action in PowerAutomate.

Run script

This is the resulting output ...

Result

From there you can use the output in the remainder of your flow. Just make sure you format your dates as need be.

You can always enhance the script if need be to do a lot more than it currently does but for the specific nature of what you're dealing with, that's simple and works nicely.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Skin