Forum Discussion
Using specific data within a column in another column in the same table
- 9 years ago
hi, try with this calculated column
FruitTotal = VAR Period = Table1[Period] RETURN CALCULATE ( SUM ( Table1[Quantity] ), FILTER ( Table1, Table1[Category] = "Fruit" && Table1[Period] = Period ) )
Fruit is the top category. I do have another grouping category between Fruit and the set {Apples, Oranges, and Bananas} called Citrus that will apply to some of the items in the set and not the others (i.e., Oranges but not Apples or Bananas), but I omitted it because I'm trying to keep things as simplified as possible. (I understand this is known as a "ragged hierarchy", i.e., one with an uneven number of levels, which is descibed here: https://msdn.microsoft.com/en-us/library/ms365406.aspx )
I should have mentioned I have accomplished what I am trying to do in SQL with similarly formatted data using windowing functions. I have read that an equivalent to windowing functions is possible with DAX's a combination of RANKX and CALCULATETABLE, likely combined with other functions, but I have not been able to make any of the examples I've seen work with this case.
And I should have also added in reply to your question that there is no Parent-Child ID column in the table.
- Vvelarde9 years ago
Community Champion
hi, try with this calculated column
FruitTotal = VAR Period = Table1[Period] RETURN CALCULATE ( SUM ( Table1[Quantity] ), FILTER ( Table1, Table1[Category] = "Fruit" && Table1[Period] = Period ) )- LandonDodge9 years ago
Microsoft Employee
Vvelarde, that worked exactly. My sincere thanks to you!
- Vvelarde9 years ago
Community Champion
Another without creating this calculated column is:
Create a Measure:
%Fruit = DIVIDE ( CALCULATE ( SUM ( Table1[Quantity] ), ALLEXCEPT ( Table1, Table1[Category], Table1[Period] ) ), ( CALCULATE ( SUM ( Table1[Quantity] ), ALLEXCEPT ( Table1, Table1[Period] ) ) - CALCULATE ( SUM ( Table1[Quantity] ), FILTER ( ALLEXCEPT ( Table1, Table1[Period] ), Table1[Category] = "Fruit" ) ) ) )And put a Matrix Visual