Forum Discussion

erihsehc's avatar
erihsehc
Helper III
8 years ago
Solved

replace measure item on matrix

hi there,

 

Below are the screenshots on matrix and data source. the Consol PAT% on matrix is not from measure, so the % is incorrect, it sum up the % from data model. I do not know how to replace those % calculation by measure (only for the % item)? not sure how to do that on matrix, please help thanks

 

Best regards

ER

 

  • Hi erihsehc,

    In excel, when the result is gotten based on rows. In Power BI, the calculation is based on column, so you need to type the original sample table below.

    sample table
    Then, create a new table using the formula below.

    Table = SUMMARIZE(Table1,Table1[item],"Sum of amt",SUM(Table1[amt]))



    Finally, get the right result by creating another new table based on the new table above.

    result = 
    UNION (
        'Table' ,
        ROW (
            "item", "3.GP%",
            "Sum of amt", DIVIDE (
                CALCULATE (
                    MAX ( 'Table'[sum of amt] ),
                    FILTER ( 'Table', 'Table'[item] = "2.GP" )
                ),
                CALCULATE (
                    MAX ( 'Table'[sum of amt] ),
                    FILTER ( 'Table', 'Table'[item] = "1.sales" )
                )
            )
        ),
        ROW (
            "item", "6.PAT%",
            "Sum of amt", DIVIDE (
                (
                    CALCULATE (
                        MAX ( 'Table'[Sum of amt] ),
                        FILTER ( 'Table', 'Table'[item] = "1.sales" )
                    )
                        - CALCULATE (
                            MAX ( 'Table'[Sum of amt] ),
                            FILTER ( 'Table', 'Table'[item] = "5.Cost" )
                        )
                ),
                CALCULATE (
                    MAX ( 'Table'[Sum of amt] ),
                    FILTER ( 'Table', 'Table'[item] = "1.sales" )
                )
            )
        )
    )
    

    expected result

    Please download the attachment to check more details.

    Best Regards,
    Angelia

9 Replies

  • Hi erihsehc

     

    If I understand, what you are looking to do, is to use only the 2 highlighted measures in your matrix?

     

     

    • erihsehc's avatar
      erihsehc
      Helper III

      hi GilbertQ, yes it is, I would like to use the measure for the 2 highlighted items in the matrix. A combination of item-measure-item-measure in the rows

      • v-huizhn-msft's avatar
        v-huizhn-msft
        Microsoft Employee

        Hi erihsehc,

        Please create some simple dummy data and list the expected result? It's really hard to reproduce your scenario without data.

        Best Regards,
        Angelia