Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Help needed to get this done.

 

My desired input table and output table. I already used the transposing method and split the query then appended that but I need to automate this without any manual interactions. 
The output should be valid even if I add more data (let us say RM = C, D, E etc...) under the input table. 

Thanks in advance.... 

  • Hi Anonymous 
    For this I would consider creating a Power Query function, you can see a Wise Owl video here.

    In brief we want to:

    • Set up a query for a single RM making it look how we want
    • Parameritise as a filter the RM
    • Create a function which can pass values to this parameters
    • Loop over a list of RM's appending everything together

     

    First create the parameter and set it to a single RM:

     

    Next filter the list you have to a single RM, the one in the parameter:

     

    Remove RM and Transpose the columns

     

    Promote the headers and then right click on the Query and choose create function:

    Connect to the data source again but this time remove other columns and duplicate:

    On the Add Columns tab choose Invoke Custom Function:

    Enjoy your end result:

    If this helped please do mark as an answer for other 🙂

8 Replies

  • Hi Anonymous 
    For this I would consider creating a Power Query function, you can see a Wise Owl video here.

    In brief we want to:

    • Set up a query for a single RM making it look how we want
    • Parameritise as a filter the RM
    • Create a function which can pass values to this parameters
    • Loop over a list of RM's appending everything together

     

    First create the parameter and set it to a single RM:

     

    Next filter the list you have to a single RM, the one in the parameter:

     

    Remove RM and Transpose the columns

     

    Promote the headers and then right click on the Query and choose create function:

    Connect to the data source again but this time remove other columns and duplicate:

    On the Add Columns tab choose Invoke Custom Function:

    Enjoy your end result:

    If this helped please do mark as an answer for other 🙂

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you so much for the reply, It was really helpful. 

    • Anonymous's avatar
      Anonymous
      Not applicable

      I am so greatful for your effort and Could you please help me to solve this one also 
      Input Table

      RMColumn 1Column 2Column3
      ATO12
      AOH22
      ADate01-01-202401-02-2024
      AStatusActualPlanned
      ATO2212
      AOH1233
      ADate01-03-202401-04-2024
      AStatusPlannedPlanned
          
      BTO810
      BOH1214
      BDate01-01-202401-02-2025
      BStatusActualActual
      BTO1223
      BOH3213
      BDate01-03-202401-04-2024
      BStatusPlannedPlanned

       my output result should be 

      Output
      RMToOHDateStatus
      A1201-01-2024Actual
      A2201-02-2024Planned
      A221201-03-2024Planned
      A123301-04-2024Planned
      B81201-01-2024Actual
      B101401-02-2025Actual
      B123201-03-2024Planned
      B231301-04-2024Planned



      • SamWiseOwl's avatar
        SamWiseOwl
        Icon for Super User rankSuper User

        Hi Anonymous ,

        What is the difference between this and the original data? If the only difference is additional lines the function can handle additional lines and columns 🙂
        If you would like the original PBIX file so you can modify click here.

        Paste the modified data into the source step of both queries or even connect to an Excel file instead.

         

        Hope this helps!

  • Step 0: I use these data below. (Date:yyyy/mm/dd)

     

    Step 1: I unpivot 2 columns on Power Query Editor.

    - Before -

    - After -

     

    Step 2: I make a matrix on Power BI Desktop.

     

     

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for you help, I have to do other visualisation too. This helps but without creating a matrix in the visualisation I want a table like that after the entire steps. Is there any more steps to add to this.