web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Dynamically Create She...
Power Automate
Unanswered

Dynamically Create Sheets with Dynamic Table Columns. Doable?

(0) ShareShare
ReportReport
Posted on by 294

HI,

I have a survey saved in a DataVerse table called "Surveys". The survey consists of categories, and each category contains a list of questions under it (e.g.

SurveyName: TestSurvey1

  • CategoryA
    • Q1UnderCategoryA
    • Q2UnderCategoryA
    • Q3UnderCategoryA
  • Category B
    • Q1UnderCategoryB
    • Q2UnderCategoryA

I would like to create a flow that creates an Excel Workbook. The name of the workbook should be "Survey Name".  Inside this workbook should be the sheets for each category (i.e. first sheet would be called "CategoryA" and second sheet called"CategoryB"). Inside each sheet, the questions should be in columns.

Important is that the categories and questions will be dynamic (i.e. different surveys will contain different categories and questions).

Is this doable? If yes, could you please walk me through it?

Thanks!

Karim

Categories:
I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @karimabdelrazek 

     

    need one confirmation on dataverse table design, would each row be each question ?

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • karimabdelrazek Profile Picture
    294 on at

    @Nived_Nambiar . Yes, that is correct.

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @karimabdelrazek 

     

    may be forget to ask a question, does survey name is also a column here ?

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • karimabdelrazek Profile Picture
    294 on at

    @Nived_Nambiar . Survey name would be the name of the Excel Workbook

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @karimabdelrazek 

     

    Ok so there would be a workbook with a name SurveyName: TestSurvey1  right ?

     

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube: Nived N's YouTube Channel
    Blog: Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

     

  • karimabdelrazek Profile Picture
    294 on at

    @Nived_Nambiar just "TestSurvey1". Apologies if I didn't clarify that in my first post.

  • Verified answer
    Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi   @karimabdelrazek 

    Finally i build a flow which is simmilar to your requirement :), learned something new while trying 🙂

    For demo purposes, i have created a survey table in dataverse like this 

     Nived_Nambiar_0-1712397842336.png

    Here category column is a choice column.

     

    Nived_Nambiar_13-1712399060893.png

     

    Also I have created a workbook named TestSurvey.xlsx and placed in SharePoint folder. 

     

    Now let's see the flow

     

    1. Use list rows to list all rows present in surveys table

     Nived_Nambiar_1-1712397933845.png

    2. use select action to select category labels like below

     Nived_Nambiar_2-1712397983820.png

    Expression - 

    item()?['cr1c0_category@OData.Community.Display.V1.FormattedValue']
     
    Note- in my case, Category is choice column and in dataverse choice column value is represented by integer, so to get the label of that i have went through attributes present in List Rows output to check which attribute contains category label , For me the above expression represent the category label.

    3. After that loop through output of select actions after applying union function/expression 

    Nived_Nambiar_3-1712398199176.png

    The next 5 steps will be done under inside the loop

    3.1 use create worksheet to create the worksheet with name of sheet as CategoryLabel 

    Nived_Nambiar_4-1712398297668.png

    3.2- use filter array to get list of all rows corresponding to category  

    Nived_Nambiar_5-1712398368672.png

    Expression used- 

    item()?['cr1c0_category@OData.Community.Display.V1.FormattedValue']
    This would be different for you (as discussed above)
     
    3.3- Now use select action to select all questions corresponding to that category
    Nived_Nambiar_16-1712399444558.png

     


    3.4 - since your table is dynamic, you need to provide dynamic range while specifying in Create Table action. So for that we need to get end column by which we can create table out of that.For that we will create office script which will take number of columns as input and give the column letter of last column as output

     

    function main(workbook: ExcelScript.Workbook, iCol: number) {
        let a: number;
        let b: number;
        a = iCol;
        let result: string = "";
        while (iCol > 0) {
            a = Math.floor((iCol - 1) / 26);
            b = (iCol - 1) % 26;
            result = String.fromCharCode(b + 65) + result;
            iCol = a;
        }
        console.log(result);
        return result;



    } 

    write this office script in the excel file and use Run script to run the script or use run script from SharePoint if your script is stored somewhere.

    Now use run script to run the above script (I have written this script in TestSurvey.xlsx so will call script from same) 

    Nived_Nambiar_7-1712398712460.png

    3.5- use create table to create table of given range like below   

    Nived_Nambiar_8-1712398787526.png

    Nived_Nambiar_14-1712399340844.pngNived_Nambiar_15-1712399357528.png

     

     

    So flow will create table with same name as of sheet.

    So you will see results like below  

     Nived_Nambiar_11-1712398975447.png

    Thanks & Regards,

    Nived N 🚀

    LinkedIn: Nived N's LinkedIn
    YouTube:
    Nived N's YouTube Channel
    Blog:
    Nived Nambiar's Blogs

    🔍 Found my answer helpful? Please consider marking it as the solution!
    Your appreciation keeps me motivated. Thank you! 🙌

  • karimabdelrazek Profile Picture
    294 on at

    @Nived_Nambiar Nice work! Amazing stuff! I am by no means a techie and the solutions I get show me just how little I know. Thank you!

  • karimabdelrazek Profile Picture
    294 on at

    @AlexEncodian. Thank you for the info. I am in the process of checking out their product set as we speak. Looks like I'm going to setup an account and explore it further. Thanks!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard