Forum Discussion
Excluding blanks and working with counts
Hello All,
I have been lurking for a little while and have to say that this is a great forum, this is my first post so please be gentle.
I am working with a dataset of weighted data and want to use the weights as values. This is simple enough, below you can see a crude example of what my data looks like:
| IceCream | Weight |
| Love It | 0.6 |
| Love It | 0.8 |
| 0.4 | |
| 0.2 | |
| Hate It | 0.5 |
| 0.2 | |
| Indifferent | 0.3 |
| Indifferent | 0.5 |
So to get a basic visual percentage, I could simply load the "weights" column into values and the "icecream" column into the axis or legend. I have two problems, I want to show single bars without the percentage being automatically summed to 100%. For example, to show "Hate It" as a % of all valid (non-blank) responses, hiding the others but not rebasing the data. The DAX I used for this is as follows:
Weight = DIVIDE(SUM(Sheet1[Weight]),CALCULATE(SUM(Sheet1[Weight]),ALL((Sheet1))))
By putting this into the value field, I can hide certain values without the percentages changing themselves, so this gets me halfway there. However, the same measure will not exclude the blanks from the "IceCream" column, so the percentages I get include blanks as part of the base calculation but I need to exclude these. Is there a DAX formula I can use which will both prevent the bars in a graph from auto adjusting as I hide them and exclude blanks from the percentage calculation? Ideally, I would also like to be able to use additional slider filters on top of this!
Thanks to anyone that can help!
1 Reply
- v-lili6-msft
Community Support
hi, PrecisePangolin
You may try this formula:
Weightm = DIVIDE(SUM(Sheet1[Weight]), CALCULATE(SUM(Sheet1[Weight]),FILTER(ALL(Sheet1),Sheet1[IceCream]<>BLANK())))
If it is not your case, please share your expected output under multiple conditions.
Best Regards,
Lin