Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Show Table Columns as Row

Hi All,

Seeking you help on my issue. I have a this table below which has a column that I need to convert as rows

BranchYearMonthTotal ProductTotal SalesHouse LoanCar LoanPreferred Client
Asia2019125    100,000.00Yes Yes
Asia202011    500,000.00 YesYes
Asia202026  2,010,150.00YesYesYes
Asia2021115      30,000.00YesYes 
Asia2021218      35,120.00   
Europe20201250    101,010.00Yes  
Europe202011100    202,020.00YesYes 
Europe2021225        5,000.00   
Europe2021320        1,000.00  Yes
Europe2021430      25,000.00 Yes 

 

I need the last 3 columns to be shown as row as shown below (summarize per branch, year and month column)

BranchYearMonthKey DriversTotal ProductTotal Sales
Asia201912House Loan5100000
Asia201912Car Loan  
Asia201912Preferred Client5100000
Asia20201House Loan  
Asia20201Car Loan1    500,000.00
Asia20201Preferred Client1    500,000.00
Asia20202House Loan6 2,010,150.00
Asia20202Car Loan6 2,010,150.00
Asia20202Preferred Client6 2,010,150.00

 

Any solution is highly appreciated.

Looking forward for you advise. Thank you!

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

     

    Just follow the formula in the article and create the following calculation table

    Table1 = 
    FILTER(
        UNION(
            SELECTCOLUMNS('Table',"Branch",[Branch],"Year",[Year],"Month",[Month],"Total Product",[Total Product],"Total Sales",[Total Sales],"Key Drivers",[Column]),
            SELECTCOLUMNS('Table',"Branch",[Branch],"Year",[Year],"Month",[Month],"Total Product",[Total Product],"Total Sales",[Total Sales],"Key Drivers",[Column 2]),
            SELECTCOLUMNS('Table',"Branch",[Branch],"Year",[Year],"Month",[Month],"Total Product",[Total Product],"Total Sales",[Total Sales],"Key Drivers",[Column 3])
    
        ),
        [Key Drivers]<>"")

     

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

6 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      thank you for your response, unfortunately the 3 columns are not available (visible) in the power query editor.

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Please kindly refer to 

    DAX Unpivot

     

    You only need one more step than the steps in the article and replace YES with the corresponding column name.

    You can create the calculated column like

    Column = IF([House Loan]="Yes","House Loan")

     

     

    Best Regards,

    Stephen Tao

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for your response and to the link to the similar query before. I need to deep dive into how I can manage those with multiple values into one column.(House Loan = YES; Preferred Client = YES)

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        Just follow the formula in the article and create the following calculation table

        Table1 = 
        FILTER(
            UNION(
                SELECTCOLUMNS('Table',"Branch",[Branch],"Year",[Year],"Month",[Month],"Total Product",[Total Product],"Total Sales",[Total Sales],"Key Drivers",[Column]),
                SELECTCOLUMNS('Table',"Branch",[Branch],"Year",[Year],"Month",[Month],"Total Product",[Total Product],"Total Sales",[Total Sales],"Key Drivers",[Column 2]),
                SELECTCOLUMNS('Table',"Branch",[Branch],"Year",[Year],"Month",[Month],"Total Product",[Total Product],"Total Sales",[Total Sales],"Key Drivers",[Column 3])
        
            ),
            [Key Drivers]<>"")

         

         

         

        Best Regards,

        Stephen Tao

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.