Forum Discussion
Sum based on sub-category
Hi all,
I am having difficulty in calculating the difference in start and end for each category based on the sub-category:
I want to show the difference between start and end. Result should be for A it is result for first row is 3, for second row is 2 so final result for A is 5. For B is 7, for C is 5, for D is 3.
Any suggestion how i can consider the sub-category in the calculation?
Thanks
Hi Taro_Gulat - you can use below dax measure :
Total Difference = SUMX('Strtend', [Sum of Start] - [Sum of End])it works as per your requirement
3 Replies
- 123abcCommunity Champion
Using DAX
Create a Calculated Column: Add a new column to calculate the difference for each row:
Row Difference = ABS([End] - [Start])This will compute the absolute difference between the Start and End values for each row.
Create a Measure for Aggregation: Create a measure to sum the differences for each Category:
Total Difference = SUM('Table'[Row Difference])If you want to see the result grouped by Category, place Category in a visual like a table or matrix and add the Total Difference measure.
Expected Result
For the given data, the expected output will look like this:
Category Total Difference
A 5 B 7 C 5 D 3 This approach ensures that the Sub-Category values are considered in the calculations and the differences are summed at the Category level.
Let me know which method you prefer or if you encounter any issues!
- rajendraongole1Super User
Hi Taro_Gulat - you can use below dax measure :
Total Difference = SUMX('Strtend', [Sum of Start] - [Sum of End])it works as per your requirement
- AnonymousNot applicable
Hi Taro_Gulat ,
Simply remove the filtering effect of column 'Sub-Category'.
Measure = CALCULATE(SUM('Table'[Start]) - SUM('Table'[End]),ALL('Table'[Sub-Category]))