Forum Discussion

Kent1341's avatar
Kent1341
Helper I
7 years ago

Including selections as text in Dax code

Hi,

 

In my product hierarchy, I have several levels. (Category, SubCategory, Segment, SubSegment 1 etc...)

 

When I calculate shares I use the following code:

 

VALUE SHARE % =
DIVIDE([VALUE];
CALCULATE([VALUE];
ALL('Product'[MANUFACTURER]);
ALL('Product'[BRAND]);
ALL('Product'[SUBCATEGORY]);
etc...))
 
This gives me the share within where 100% is total Category also when I eg look at a SubCategory's share of the Category
However - sometimes when I look into a Brand I want to look at a brands share within a SubCategory, and then I need the formula without the line "ALL('Product'[SUBCATEGORY]);"
 
So - I would like the DAX code to react on selections I make in a slicer. What I select will then be 100% / ALL in the calculation. 
I have a table with the texts I need to be in the formula, but where do I go from there?
 
 
Br Kent