Forum Discussion
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
- AnonymousNot applicable
Show the model.
- AnonymousNot applicable
When you say the model, are you referring to the underlying data?
- AnonymousNot applicable
No, I'm referring to the schema.
- amitchandakSuper User
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])))- AnonymousNot 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.
- AnonymousNot 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?
- AnonymousNot applicable
So it's using the two tables I've highlighted.
So it's using the two tables I've highlighted