Forum Discussion
Bhatt23
Helper I
2 years agoGrouping for multiple calculation (sum and substract) with respect to categories
Hi Guys, Can anyone please help me on this problem. Here I have one table with the mapping data along with calculation and other one with the data itself. How can we implement the formula in...
- Anonymous2 years ago
Hi Bhatt23
Based on your description, if there are no calculation group, will they shold be sum together? such as the BN101.
I create the following sample based on the understanding I have described, you can refer it.
Sample data is the same as you provided.
Create the following measures.
Calculation_group = MAXX ( FILTER ( ALLSELECTED ( 'Formula with mapping' ), [Division] IN VALUES ( 'Data'[Division] ) && [Subdivision] IN VALUES ( 'Data'[Subdivision] ) ), [Calculation based on DPID which represent Subdivision] )Left_calculation = LEFT([Calculation_group],SEARCH(")",[Calculation_group],,BLANK()))Right_calculation = RIGHT([Calculation_group],LEN([Calculation_group])-SEARCH(")",[Calculation_group],,BLANK()))Sum_calculation = VAR a = SUMX ( FILTER ( ALLSELECTED ( 'Data' ), [Division] IN VALUES ( 'Data'[Division] ) && [Subdivision] IN VALUES ( 'Data'[Subdivision] ) && CONTAINSSTRING ( [Left_calculation], [DPID] ) ), [VALUE] ) VAR b = SUMX ( FILTER ( ALLSELECTED ( 'Data' ), [Division] IN VALUES ( 'Data'[Division] ) && [Subdivision] IN VALUES ( 'Data'[Subdivision] ) && CONTAINSSTRING ( [Right_calculation], [DPID] ) ), [VALUE] ) RETURN SWITCH ( TRUE (), [Calculation_group] = BLANK (), SUMX ( FILTER ( ALLSELECTED ( 'Data' ), [Division] IN VALUES ( 'Data'[Division] ) && [Subdivision] IN VALUES ( 'Data'[Subdivision] ) ), [VALUE] ), [Left_calculation] = BLANK (), b, [Left_calculation] <> BLANK (), a - b )Output
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Bhatt23
Helper I
2 years ago