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
- Anonymous2 years agoNot applicable
Sorry, I meant the tables that create your data model and their relationships, I think that will be where the issue lies. I assumed how they were setup but if you have created the relationships differently to my assumption then the measures would need tweaking based on that, I'll try building an example .pbix and test the results
- migueldfr2 years agoHelper IV
I can send yopu the data, but I don't know how to send to you.
Thanks
- Anonymous2 years agoNot applicable
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])))