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])))
Hi Anonymous
Thank you for the answer.
But i tried to create that measure and get into my chart, but It doesn't work.
the code i wrote it down is same, but changing my names, obvisusly.
What could it be ?
Thank you
Would be good if you can send me some sample data so I can play around with it myself if possible. Looking at it returning 100% everywhere though it would infer that the two variables in the measure are returning the same thing. Are the values for the stores in a separate table? You'd want the table inside FILTER(ALL()) to be the table with your stores and sales numbers, try the below unless this is already what you've done:
VAR _sales = SUM('YourSALESTable'[Sales])
VAR _sales_this_year = CALCULATE(_sales, FILTER(ALL(YourSALESTable),
YEAR(SELECTEDVALUE('YourDATETable'[Date])) = YEAR('YourSALESTable'[Date]))
RETURN
DIVIDE(_sales, _sales_this_year, 0)
The argument with YourDATETable should be whichever date field you have in the graph visual itself. If none of that then I'd guess that the legend is potentially just a year column and not a date column? If that is the case you can try the following:
VAR _sales = SUM('YourSALESTable'[Sales])
VAR _sales_this_year = CALCULATE(_sales, FILTER(ALL(YourSALESTable),
SELECTEDVALUE('YourDATETable'[Year]) = YEAR('YourSALESTable'[Date]))
RETURN
DIVIDE(_sales, _sales_this_year, 0)
If none of that works, I'd need to see the data myself, hope this helps, let me know how you get on.