Forum Discussion
Adding a slicer from different columns; calculating sum based on values in other columns
- 6 years ago
Hello Anonymous
For the first problem, I would recommend you to transform your table using Power Query:
Unpivot your value columns:
Split the Attribute column(earlier headers) to create two separate columns:
This way you should be able to filter your visuals using slicers:
For the % share, it is not very clear what is the output you are looking for. Is this the output you are looking for?
I have created following measures for this:
Total fruits = CALCULATE ( SUMX ( dtTable, IF ( dtTable[Category] = "fruits", dtTable[Value] ) ), ALLEXCEPT ( dtTable, dtTable[Category] ) ) Total Vegetables = CALCULATE ( SUMX ( dtTable, IF ( dtTable[Category] = "Vegetables", dtTable[Value] ) ), ALLEXCEPT ( dtTable, dtTable[Category] ) ) % Share fruits = DIVIDE(SUM(dtTable[Value]),[Total fruits]) % Share Vegetables = DIVIDE(SUM(dtTable[Value]),[Total Vegetables])You may find the solution pbix file here
Regards,
Vivek
If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂
https://www.vivran.in/
Hello Anonymous
For the first problem, I would recommend you to transform your table using Power Query:
Unpivot your value columns:
Split the Attribute column(earlier headers) to create two separate columns:
This way you should be able to filter your visuals using slicers:
For the % share, it is not very clear what is the output you are looking for. Is this the output you are looking for?
I have created following measures for this:
Total fruits =
CALCULATE (
SUMX ( dtTable, IF ( dtTable[Category] = "fruits", dtTable[Value] ) ),
ALLEXCEPT ( dtTable, dtTable[Category] )
)
Total Vegetables =
CALCULATE (
SUMX ( dtTable, IF ( dtTable[Category] = "Vegetables", dtTable[Value] ) ),
ALLEXCEPT ( dtTable, dtTable[Category] )
)
% Share fruits = DIVIDE(SUM(dtTable[Value]),[Total fruits])
% Share Vegetables = DIVIDE(SUM(dtTable[Value]),[Total Vegetables])
You may find the solution pbix file here
Regards,
Vivek
If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂
https://www.vivran.in/
Hi vivran22
Thank you so much for your reply! The slicer solution worked perfectly.
For the share part, it works, but the problem is that I have a lot of categories and can't introduce them manually. Is there any way of calculating without adding the name of it? And I have to calculate the share for other indicators as well. Sorry, my first explanation was not the most understandable.
In the Period columns I have sales values. I have to have 3 types of analysis:
- one for brand level, splited by market. The category should have 100% in all market types, 100% in Sales and 100% in Volum.
- one for supplier level, spilited by market. Also the category should have 100% in all market types, 100% in Sales and 100% in Volum.
I have created a draft report, with how it should look like: (Private label is just another column where I have "Private label" and "No private label".). The example is for Brand level, I also have to have it for supplier level; and also with the slicer for Period 1 or Period 2.
I hope I explained it right.
Thank you so much again!
- vivran226 years ago
Community Champion
Hey,
Still not very clear in terms of output required
Is this kind of calculation/value you are looking at?
Regards,
Vivek
If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂
https://www.vivran.in/- Anonymous6 years agoNot applicable
Hi vivran22 ,
I think I figured it out. This is how it should look like:
Each channel(hypermarket, supermarket, country, etc) should have 100%. I used unpivot columns for "Brand and Supplier" to be able to use it as slicer(in an Attribute column), like you advised me. I used the following formula for value % share:
Value % Share = 'Table'[Period 1 This year]/calculate(sum(Table[Period 1 This year]);ALLEXCEPT(Table;Table[MARKET];Table[Measure];Table[CATEGORY];Table[Attribute]))I think I will make 2 reports, one for period 1 and one for period 2.
Thank you again!!
Diana