"Switch" question

Options

Good morning, all! I'm working on a Word report that is populated by Power Automate data. Have the template set up and am getting data through, but my question is about a Switch I'd like to implement to avoid having to switch the constituent list that's pulled each time the report is run. [In the grand scheme of things, not the biggest deal, and it's probably best NOT to go down this rabbit hole, but as I'm trying to expand my education, I'm having difficulty solving my problem.]

We have four different versions of the report – though it really is just switching the title of the report, which is handled just fine through the input of the flow – but in addition to the result of the input drop-down changing the name of the report, I'd like it to also switch which of four different constituent lists to iterate through the flow.

My problem is that the majority of my flow depends on that constituent list (and the “Apply to Each” for each person in the constituent list), and since there have to be unique names for each piece of the flow, I can't figure out how to have a switched list have a consistent name that the rest of the flow can reference. Does that make sense? Any ideas?

Comments

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary 1,500 Likes 2500 Comments Name Dropper

    @Advancement Division
    Don't use a switch on the constituent list action

    setup a string variable, switch and set the variable value to the list id (not name of list, you will need to find out the list id)

    then constituent list action on the parameter for list, select to use custom and use the variable

    there will only be one constituent list action, and all your subsequent actions that reference the constituent list will remain the same

  • @Alex Wong First off, forgot that I was logged in under the account that has our PA license and not me (i.e. I'm the thread's OP ?). Thanks for the reply!

    I had an epiphany: Would running coalesce() on the various list values not work? For example, coalesce(outputs('SwitchList1')?['body/value'],outputs('SwitchList2')?['body/value'],outputs('SwitchList3')?['body/value'],outputs('SwitchList4')?['body/value'])

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary 1,500 Likes 2500 Comments Name Dropper

    @Kevin Fletcher
    coalesce should work too, there's always more than one way to an end goal in Power Automate and Power BI

  • Alex Wong
    Alex Wong Community All-Star
    Ninth Anniversary 1,500 Likes 2500 Comments Name Dropper

    @Kevin Fletcher
    just one point,

    if you have multiple constituent list action, while in the Apply to Each you can use coalesce, every action thereafter will require you to “coalesce”. (for example, if in your subsequent action you are using the count property), in some situation coalsesce may not work.

Categories