Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Ratio Calculation

I need to calculate a ratio. I have a table with one column for the amount. There is a column that holds the ClientID and another column that holds the Sub Account for those ClientID. A ClientID ma...
  • quantumudit's avatar
    quantumudit
    2 years ago

    You don't need a data model for this but, if you have a model, still this formula will work. Here is the DAX measure that you can use:

    Ratio = 
    VAR _clientTotal =
        CALCULATE (
            SUM ( MainTable[Amount] ),
            FILTER (
                ALL ( MainTable ),
                MainTable[ClientID] = SELECTEDVALUE ( MainTable[ClientID] )
            )
        )
    VAR _ratio =
        DIVIDE ( SUM ( MainTable[Amount] ), _clientTotal )
    RETURN
        _ratio

     

    Well instead of  SUM ( MainTable[Amount] ) you can create a simple measure like this and use it too:

     

    Total Amount = SUM ( MainTable[Amount] )

     

    Here is the screenshot of the solution:

    Hope this will resolve your issue.

     

    Best Regards,
    Udit

    If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudo 👍

    🚀 Let's Connect: LinkedIn || YouTube || Medium || GitHub
    Visit My Linktree: LinkTree