Forum Discussion
Two Bar chart separate with different values
- 2 years ago
Here, i upload and example:
Ç
I create a table with values and the stores but as you see, the TG% de CANT. is not calullating the values by the total of that colum, it is calcullating by the total of all table...
I don't want that, I would like to visualize the data for 2022 showing the percertage of that year, and same 2023, but separatly.
Thank you
- 2 years ago
I found my issue, the right code was this:
CategoriaPorcentajeCOUNT (subcate) =DIVIDE(COUNTX('Table', 1),CALCULATE(COUNTX('table', 1), ALLSELECTED('table'[category])))
Here, i upload and example:
Ç
I create a table with values and the stores but as you see, the TG% de CANT. is not calullating the values by the total of that colum, it is calcullating by the total of all table...
I don't want that, I would like to visualize the data for 2022 showing the percertage of that year, and same 2023, but separatly.
Thank you
Think I found the issue!
See above, I believe this is working as you want, though not on the same visual, just easier for me to look at, I replaced the _sales argument in _sales_this_year with SUM('YourTable'[Sales]) and it works. I imagine this is something to do with variables having a fixed value after declaring them and then not obeying filter context, not sure why but it seems to be what's happening in this case, could be something to do with calculate also.
- migueldfr2 years agoHelper IV
I found my issue, the right code was this:
CategoriaPorcentajeCOUNT (subcate) =DIVIDE(COUNTX('Table', 1),CALCULATE(COUNTX('table', 1), ALLSELECTED('table'[category])))