Forum Discussion

pmdci's avatar
pmdci
Advocate V
10 years ago
Solved

Showing percentage values in visuals

Hi there,   I have created measures in the past based on COUNTX which when combined with COUNTROWS I can create some percentage measures. For instance if I do a count of all rows where PRODUCT = "A...
  • greggyb's avatar
    10 years ago

    You can't have totally dynamic percentages. You must define a base measure to use as numerator, and a measure that removes some filter context to create a denominator, you can then calculate the percentage using these components.

     

    The following idiom should get you there:

    Base =
    COUNTROWS( 'Table' )
    
    Denominator =
    CALCULATE(
        [Base]
        ,ALLSELECTED()
    )
    
    Percentage =
    DIVIDE( [Base], [Denominator] )

    Depending on your specific use case you may need to call out specific columns or tables in the ALLSELECTED()