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])))
The following should work:
Test =
VAR _sales = SUM('YourTable'[Sales])
VAR _sales_this_year = CALCULATE(_sales, FILTER(ALL(YourTable),
YEAR(SELECTEDVALUE('YourTable'[Date])) = YEAR('YourTable'[Date]))
RETURN
DIVIDE(_sales, _sales_this_year, 0)
This effectively returns the total sales respective of the data and store, divided by the total sales only respecting the year context which should be what you're after. Hope this helps, let me know if you have any issues or further questions.