Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago

Count Rows based on dynamic column value

Hi, I have a stacked bar chart with a line graph on and as a tooltip, I want to show the percentage value of each stack. I've tried various solutions, but to no avail. For example, for 2019, when I hover over the bottom stack, I want the tooltip to tell me that it represents XX% of uploads for non-partners that year.

 

I've tried the solution below, but the latter part of the argument returns the total number of rows within the table, not the amount for each year.

 

Percentage = DISTINCTCOUNT('Overview'[First_NID])/CALCULATE(DISTINCTCOUNT(Overview[First_NID]),ALLEXCEPT(Overview,Overview[First_Year]))

9 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Show the model.

    • Anonymous's avatar
      Anonymous
      Not applicable

      When you say the model, are you referring to the underlying data?

      • Anonymous's avatar
        Anonymous
        Not applicable

        No, I'm referring to the schema.

  • Anonymous , try a measure like


    Percentage = divide(DISTINCTCOUNT('Overview'[First_NID]),CALCULATE(DISTINCTCOUNT(Overview[First_NID]),filter(allselected(Overview),Overview[First_Year]) =max(Overview[First_Year])))

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks, amitchandak! However, it's still not working. I receive the following error message - A function 'FILTER' has been used in a True/False expression that is used as a table filter expression. This is not allowed.

  • Anonymous's avatar
    Anonymous
    Not applicable

    I smell a rat here... The rat being a single-table model. Do you happen to have a model with just one big table?

    • Anonymous's avatar
      Anonymous
      Not applicable

       

      So it's using the two tables I've highlighted.

      So it's using the two tables I've highlighted