Forum Discussion

NishPatel's avatar
NishPatel
Resolver II
4 years ago
Solved

Two column with grouped rows

Hi,

Is it possible to create below matrix in power BI?

 

  • NishPatel 

    Thanks for that. It really helps.

    Caveat: this example follows the criteria laid out in your latest data sample. In other words, the % split by cost type is the same for each company. If the split is different for each company, we need a table with the detailed % split by cost type and by company to make the correct calculations

    Ok, here is one way. You need to create intermediate tables in Power Query for the % calculations (which involves custom - calculated- columns and unpivotting) to finally append them all in a final table. Just beware that every cost type must have a % split summing to 100% (I've added a new calulation in the Spare Parts Table costs for the 80% not accounted for in your example). This way the sum of cost breakdown will equal the sum of the corresponding amount.

    The table looks like this:

    You can then use the Cost Type and Cost Breakdown fields to structure the matrix. The measure is a simple sum:

    By cost type

     

    By company

     

     

    I've attached the sample PBIX file

13 Replies

    • NishPatel's avatar
      NishPatel
      Resolver II

      Hi Amit,

      I am not sure how to upload a file here and that's why i pasting below sample raw data. I appreciate your help.

       

      YearMonthAmountTypeCompanyInvoiceNo
      2021Apr205XCompany A001
      2021Apr627YCompany A001
      2021Apr583ZCompany A001
      2021Apr738XCompany B001
      2021Apr160YCompany B001
      2021Apr374ZCompany B001
      2021Apr291XCompany C001
      2021Apr442YCompany C001
      2021Apr769ZCompany C001
      2021Apr647XCompany A002
      2021Apr954YCompany A002
      2021Apr153ZCompany A002
      2021Apr185XCompany B002
      2021Apr983YCompany B002
      2021Apr923ZCompany B002
      2021Apr233XCompany C002
      2021Apr297YCompany C002
      2021Apr149ZCompany C002
      2021May314XCompany A003
      2021May747YCompany A003
      2021May784ZCompany A003
      2021May438XCompany B003
      2021May540YCompany B003
      2021May223ZCompany B003
      2021May426XCompany C003
      2021May640YCompany C003
      2021May360ZCompany C003
      2021May907XCompany A004
      2021May879YCompany A004
      2021May865ZCompany A004
      2021May603XCompany B004
      2021May622YCompany B004
      2021May223ZCompany B004
      2021May580XCompany C004
      2021May953YCompany C004
      2021May682ZCompany C004
      2021Jun142XCompany A005
      2021Jun122YCompany A005
      2021Jun887ZCompany A005
      2021Jun510XCompany B005
      2021Jun925YCompany B005
      2021Jun614ZCompany B005
      2021Jun563XCompany C005
      2021Jun230YCompany C005
      2021Jun240ZCompany C005
      2021Jun144XCompany A006
      2021Jun679YCompany A006
      2021Jun216ZCompany A006
      2021Jun257XCompany B006
      2021Jun820YCompany B006
      2021Jun928ZCompany B006
      2021Jun309XCompany C006
      2021Jun868YCompany C006
      2021Jun853ZCompany C006
      2021Jul349XCompany A007
      2021Jul853YCompany A007
      2021Jul664ZCompany A007
      2021Jul543XCompany B007
      2021Jul829YCompany B007
      2021Jul700ZCompany B007
      2021Jul387XCompany C007
      2021Jul789YCompany C007
      2021Jul382ZCompany C007
      2021Jul172XCompany A008
      2021Jul113YCompany A008
      2021Jul657ZCompany A008
      2021Jul577XCompany B008
      2021Jul201YCompany B008
      2021Jul691ZCompany B008
      2021Jul889XCompany C008
      2021Jul935YCompany C008
      2021Jul620ZCompany C008
      2021Aug239XCompany A009
      2021Aug216YCompany A009
      2021Aug586ZCompany A009
      2021Aug748XCompany B009
      2021Aug759YCompany B009
      2021Aug848ZCompany B009
      2021Aug309XCompany C009
      2021Aug202YCompany C009
      2021Aug118ZCompany C009
      2021Aug770XCompany A010
      2021Aug777YCompany A010
      2021Aug738ZCompany A010
      2021Aug476XCompany B010
      2021Aug1000YCompany B010
      2021Aug763ZCompany B010
      2021Aug194XCompany C010
      2021Aug458YCompany C010
      2021Aug902ZCompany C010

       

      • PaulDBrown's avatar
        PaulDBrown
        Community Champion

        Ideally (best practices) you sould create dimension tables for the non-value columns (those you will be using to filter by). In this example I've only created a dimension table for month (to ensure proper sorting)

        Then with a simple sum measure

        Sum Amount = SUM(FactTable[Amount])

        and this structure for a matrix visual

         and drilling down on rows and columns

         

         

        you get