Forum Discussion

devdev's avatar
devdev
New Member
1 year ago
Solved

DAX for percentage values

I need percentage values as described in the table in the right side

For example : 

High -cost is showing 51%. This we are getting when we divide 171,915,156 / 335,631,725 

Similarly Medium-cost is showing 2% . This we are getting 7,920,658 / 335,631,725

 

How is this achievable using DAX?

 

  • FBergamaschi's avatar
    FBergamaschi
    1 year ago

    % of Grand Total = 
    DIVIDE(
        SUM(CostTable[CostReceiving]),
        CALCULATE(SUM(CostTable[CostReceiving]), ALL(CostTable[Cost Sending]), ALL( CostTable[Cost Receiving]))
    )

     

    Sorry I had forgotten another filter to remove

     

    If it works, please give kudos and mark as a solution, if it does not please specify all the columns that are grouped in Filters, Rows and columns section of the pivot table

     

    Thanks

10 Replies

  • Hi devdev 

     

    The following dax measure should make the calculation you need

     

    Percentage of Total Cost =
    DIVIDE(
    SUM('YourTable'[CostValue]),
    CALCULATE(
    SUM('YourTable'[CostValue]),
    ALL('YourTable'[CostCategory])
    )
    )

    If it is not working, do not hesistate to show with many countries what you are trying to achieve

    • devdev's avatar
      devdev
      New Member

      Hi Cookistador , THis is not giving correct result
      More examples for you below:

       

      For Europe region:  501,679,459 / 752,307,107 gives 67%

  • v-sgandrathi's avatar
    v-sgandrathi
    Icon for Community Support rankCommunity Support

    Hi devdev,

    Thank you for reaching out to the Microsoft Fabric Community Forum.

     

    Create New measure

    % of Grand Total = 
    DIVIDE(
        SUM(CostTable[CostReceiving]),
        CALCULATE(SUM(CostTable[CostReceiving]), ALL(CostTable))
    )

     

    Format the measure

    Select your new measure.

    Navigate to Measure Tools > Format > Percentage.

    Set it to display 2 decimal places, or adjust as needed.

     

    Add the measure to the Matrix

    Drag the % of Grand Total measure into the Values area of your Matrix.

    This will instantly display both absolute values and percentages in separate lines for each region-category.

     

    I have included the PBIX file that I created using the provided sample data. Kindly review it and confirm whether it aligns with your expectations.

     

    If this solution worked for you, kindly mark it as Accept as Solution and feel free to give a Kudos, it would be much appreciated!

     

    Thank you.

  • % of Grand Total = 
    DIVIDE(
        SUM(CostTable[CostReceiving]),
        CALCULATE(SUM(CostTable[CostReceiving]), ALL(CostTable[Cost Sending]))
    )

     

    I hope I typed the column name corectly, you do not want to remove all filters

     

    If it works, please give kudos and mark as a solution

     

    Thanks

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

      % of Grand Total = 
      DIVIDE(
          SUM(CostTable[CostReceiving]),
          CALCULATE(SUM(CostTable[CostReceiving]), ALL(CostTable[Cost Sending]), ALL( CostTable[Cost Receiving]))
      )

       

      Sorry I had forgotten another filter to remove

       

      If it works, please give kudos and mark as a solution, if it does not please specify all the columns that are grouped in Filters, Rows and columns section of the pivot table

       

      Thanks

  • v-sgandrathi's avatar
    v-sgandrathi
    Icon for Community Support rankCommunity Support

    Hi devdev,

     

    Has your issue been resolved?
    If the response provided by FBergamaschi  addressed your query, could you please confirm? It helps us ensure that the solutions provided are effective and beneficial for everyone.

    If yes, kindly accept the useful reply as a solution and give us Kudos. It would be appreciated.

     

    Thank you for your understanding!

    • v-sgandrathi's avatar
      v-sgandrathi
      Icon for Community Support rankCommunity Support

      Hi devdev,

       

      We wanted to check if you had a chance to review our last reply. Let us know if it helped or if you need more guidance, we're always happy to help further.

      Looking forward to hearing from you!

      • v-sgandrathi's avatar
        v-sgandrathi
        Icon for Community Support rankCommunity Support

        Hi devdev,

         

        Just wanted to check regarding your question. We haven’t heard back and want to ensure you're not stuck. If you need anything else or have updates to share, we’re here to help!

        If the previous reply resolved your issue, please consider marking it as Accepted and giving it a Kudos to help others find it easily.

         

        If it's resolved, feel free to hit Accept as Solution and drop a Kudos.