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 ) )
you have only these category values in table (Fruit->Apples, Oranges, Bananas etc.) or do you have some another (Vegetable -> tomato.... etc.)? Is there some Parent-Child ID column in table?
Regards.
Pavel
- LandonDodge9 years ago
Microsoft Employee
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.
- LandonDodge9 years ago
Microsoft Employee
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 ) )