Forum Discussion
Grouping 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 a single column to group it with Subdivision column and Division.
So the end result should look like the view in end result view below which will group by subdivision and division but the value is as per the calculation mentioned in the calculation sheet tab.
Your help or guidance is really appreciated.
Thanks!
Formula with mapping view
| DPID | Division | Subdivision | Calculation based on DPID which represent Subdivision | Names for calculation |
| 9680 | A | API 1 | (9680+9711)-9692-9677 | API 1 |
| 9692 | A | API 1 | ||
| 9677 | A | API 1 | ||
| 9706 | S | BN101 | ||
| 9711 | A | API 1 | ||
| 9709 | P | BR1 | ||
| 9689 | P | BR2 | ||
| 9686 | P | APA 1 | 9686+9674+9710+9675+9670+9678 | APA 1 |
| 9691 | P | APA 1 Test | 9691+9672+9687+9671 | APA 1 Test |
| 9672 | P | APA 1 Test | ||
| 9701 | N | Not known | ||
| 9676 | N | Not known | ||
| 9710 | P | APA 1 | ||
| 9674 | P | APA 1 | ||
| 9703 | A | API Endurance | 9702+9688+9703 | API Endurance |
| 9687 | P | APA 1 Test | ||
| 9678 | P | APA 1 | ||
| 9670 | P | APA 1 | ||
| 9671 | P | APA 1 Test | ||
| 9702 | A | API Endurance | ||
| 9688 | A | API Endurance | ||
| 9675 | p | APA 1 | ||
| 9679 | F | CR1 | ||
| 9697 | F | CR2 | ||
| 9699 | S | AID_ASC | 9699+9708 | AID_ASC |
| 9708 | S | AID_ASC | ||
| 9705 | P | APA 2 | (9705+9704)-9693-9673 | APA 2 |
| 9693 | P | APA 2 | ||
| 9673 | P | APA 2 | ||
| 9704 | P | APA 2 | ||
| 9694 | F | APF End Test | 9694+9700 | APF End Test |
| 9700 | F | APF End Test | ||
| 9682 | Y | YR1 | ||
| 9696 | Y | YR2 | ||
| 9690 | SAS | P & P + Warmtepomp | ||
| 9685 | SAS | HVAC EB A15 | ||
| 9683 | F | APF Labo | ||
| 9684 | SAS | MT111 | ||
| 9695 | SAS | MT112 | ||
| 9698 | SAS | MT110 | 9684+9695 | SAS |
| 9707 | F | APF Labo | 9683+9707 | APF Labo |
| 9681 | M | HR1 | ||
| 9748 | SMP | HR2 | ||
| 9747 | SMP | HR3 | ||
| 9753 | SMP | HR4 | ||
| 9752 | SMP | HR8 | ||
| 9751 | SMP | HR11 | ||
| 9750 | SMP | HR12 | ||
| 9746 | SMP | HR14 | ||
| 9749 | SMP | HR12 | ||
| 9693 | A | API 2 | 9693+9673 | API 2 |
| 9673 | A | API 2 |
Data view
| DPID | Division | Subdivision | VALUE |
| 9680 | A | API 1 | 12 |
| 9692 | A | API 1 | 13 |
| 9677 | A | API 1 | 15 |
| 9706 | S | BN101 | 17 |
| 9711 | A | API 1 | 200 |
| 9709 | P | BR1 | 165.4 |
| 9689 | P | BR2 | 203.4 |
| 9686 | P | APA 1 | 241.4 |
| 9691 | P | APA 1 Test | 279.4 |
| 9672 | P | APA 1 Test | 317.4 |
| 9701 | N | Not known | 355.4 |
| 9676 | N | Not known | 393.4 |
| 9710 | P | APA 1 | 431.4 |
| 9674 | P | APA 1 | 469.4 |
| 9703 | A | API Endurance | 507.4 |
| 9687 | P | APA 1 Test | 545.4 |
| 9678 | P | APA 1 | 583.4 |
| 9670 | P | APA 1 | 621.4 |
| 9671 | P | APA 1 Test | 659.4 |
| 9702 | A | API Endurance | 697.4 |
| 9688 | A | API Endurance | 735.4 |
| 9675 | p | APA 1 | 773.4 |
| 9679 | F | CR1 | 811.4 |
| 9697 | F | CR2 | 849.4 |
| 9699 | S | AID_ASC | 887.4 |
| 9708 | S | AID_ASC | 925.4 |
| 9705 | P | APA 2 | 963.4 |
| 9693 | P | APA 2 | 1001.4 |
| 9673 | P | APA 2 | 1039.4 |
| 9704 | P | APA 2 | 1077.4 |
| 9694 | F | APF End Test | 1115.4 |
| 9700 | F | APF End Test | 1153.4 |
| 9682 | Y | YR1 | 1191.4 |
| 9696 | Y | YR2 | 1229.4 |
| 9690 | SAS | P & P + Warmtepomp | 1267.4 |
| 9685 | SAS | HVAC EB A15 | 1305.4 |
| 9683 | F | APF Labo | 1343.4 |
| 9684 | SAS | MT111 | 1381.4 |
| 9695 | SAS | MT112 | 1419.4 |
| 9698 | SAS | MT110 | 1457.4 |
| 9707 | F | APF Labo | 1495.4 |
| 9681 | M | HR1 | 1533.4 |
| 9748 | SMP | HR2 | 1571.4 |
| 9747 | SMP | HR3 | 1609.4 |
| 9753 | SMP | HR4 | 1647.4 |
| 9752 | SMP | HR8 | 1685.4 |
| 9751 | SMP | HR11 | 1723.4 |
| 9750 | SMP | HR12 | 1761.4 |
| 9746 | SMP | HR14 | 1799.4 |
| 9749 | SMP | HR12 | 1837.4 |
| 9693 | A | API 2 | 1875.4 |
| 9673 | A | API 2 | 1913.4 |
| 9680 | A | API 1 | 1951.4 |
| 9692 | A | API 1 | 1989.4 |
| 9677 | A | API 1 | 2027.4 |
| 9706 | S | BN101 | 2065.4 |
| 9711 | A | API 1 | 2103.4 |
| 9709 | P | BR1 | 2141.4 |
| 9689 | P | BR2 | 2179.4 |
| 9686 | P | APA 1 | 2217.4 |
| 9691 | P | APA 1 Test | 2255.4 |
| 9672 | P | APA 1 Test | 2293.4 |
| 9701 | N | Not known | 2331.4 |
| 9676 | N | Not known | 2369.4 |
| 9710 | P | APA 1 | 2407.4 |
| 9674 | P | APA 1 | 2445.4 |
| 9703 | A | API Endurance | 2483.4 |
| 9687 | P | APA 1 Test | 2521.4 |
| 9678 | P | APA 1 | 2559.4 |
| 9670 | P | APA 1 | 2597.4 |
| 9671 | P | APA 1 Test | 2635.4 |
| 9702 | A | API Endurance | 2673.4 |
| 9688 | A | API Endurance | 2711.4 |
| 9675 | p | APA 1 | 2749.4 |
| 9679 | F | CR1 | 2787.4 |
| 9697 | F | CR2 | 2825.4 |
| 9699 | S | AID_ASC | 2863.4 |
| 9708 | S | AID_ASC | 2901.4 |
| 9705 | P | APA 2 | 2939.4 |
| 9693 | P | APA 2 | 2977.4 |
| 9673 | P | APA 2 | 3015.4 |
| 9704 | P | APA 2 | 3053.4 |
| 9694 | F | APF End Test | 3091.4 |
| 9700 | F | APF End Test | 3129.4 |
| 9682 | Y | YR1 | 3167.4 |
| 9696 | Y | YR2 | 3205.4 |
| 9690 | SAS | P & P + Warmtepomp | 3243.4 |
| 9685 | SAS | HVAC EB A15 | 3281.4 |
| 9683 | F | APF Labo | 3319.4 |
| 9684 | SAS | MT111 | 3357.4 |
| 9695 | SAS | MT112 | 3395.4 |
| 9698 | SAS | MT110 | 3433.4 |
| 9707 | F | APF Labo | 3471.4 |
| 9681 | M | HR1 | 3509.4 |
| 9748 | SMP | HR2 | 3547.4 |
| 9747 | SMP | HR3 | 3585.4 |
| 9753 | SMP | HR4 | 3623.4 |
| 9752 | SMP | HR8 | 3661.4 |
| 9751 | SMP | HR11 | 3699.4 |
End result view
| Division | Subdivision | Value(example not real calculation)[calculation should be with respect to calculation sheet] |
| A | API 1 | 60 |
| S | BN101 | 450 |
| P | BR1 | 330 |
| P | BR2 | 123 |
| P | APA 1 | 156 |
| P | APA 1 Test | 183.3 |
| N | Not known | 169.8 |
| A | API Endurance | 156.3 |
| F | CR1 | 142.8 |
| F | CR2 | 129.3 |
| S | AID_ASC | 115.8 |
| P | APA 2 | 102.3 |
| F | APF End Test | 88.8 |
| Y | YR1 | 75.3 |
| Y | YR2 | 61.8 |
| SAS | P & P + Warmtepomp | 48.3 |
| SAS | HVAC EB A15 | 34.8 |
| F | APF Labo | 21.3 |
| SAS | MT111 | 7.8 |
| SAS | MT112 | -5.7 |
| SAS | MT110 | -19.2 |
| M | HR1 | -32.7 |
| SMP | HR2 | -46.2 |
| SMP | HR3 | -59.7 |
| SMP | HR4 | -73.2 |
| SMP | HR8 | -86.7 |
| SMP | HR11 | -100.2 |
| SMP | HR12 | -113.7 |
| SMP | HR14 | -127.2 |
- 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.
15 Replies
- AnonymousNot applicable
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
Hi Yolo,
Thanks for your response really appreciate for helping me here.
Actually answering to your question
"Based on your description, if there are no calculation group, will they shold be sum together? such as the BN101"
Well that actually depends like in few cases they will be taken as it is like in BN101 case as it is sum of all BN101.
But in other cases according to different logics subdivision can be sum like YR1 and YR2 which will be sum YR1+YR2.
Also Is there a way we can keep all formulas in a column according to let's say divisions or subdivision and once any row is update in formula or any new division subdivision added than it should take the new ones too.
If require we can connect separately to discuss this please for better understanding of problem.
Thanks,
Bhatt- AnonymousNot applicable
Hi Bhatt23
Thanks for your quick reply, but on your Formula with mapping view, you don't give the calculation rule like YR1 and YR2, the calculation i offered based on the calculation rule on Formula with mapping view. and the measures i offered will change if you change the formula, if you think the solution i offered above, you can consider to mark it as a solution, and based on your new requirement, you can open a new case.
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
I will mark this as accepted solution for this scenario and probably will raising a new request for the other realtime data and scenario.
- Bhatt23
Helper I
Hi Yolo,
I tested and it failed.
I forgot to mention few important things:-
The data table consist of Date and time column which is every mins or hours data and the number of rows are more than 200K.
So when I tested this with actual data to see the trend via bar chart it failed with error visual has exceeded the available resources.
Sorry but I should have mentioned these points in the beginning.
So the data table is created after merging the formula with mapping table to data that means data table as separate only consist of DPID, Value and date/time however merging it with Mapping table via DPID gives me the main data table that is as below on which I did calculation and it failed to show me correct result.DPID Division Subdivision Value Date and time 9680 A API 1 16.493 2024-04-22T12:15:38.2500000 9692 A API 1 16.508 2024-04-24T02:38:43.7600000 9677 A API 1 16.512 2024-04-24T12:38:47.7500000 9706 S BN101 16.519 2024-04-25T07:00:18.2500000 9711 A API 1 16.521 2024-04-25T12:45:46.7500000 9709 P BR1 16.525 2024-04-25T23:38:59.7500000 9689 P BR2 16.535 2024-04-27T06:09:10.5400000 9686 P APA 1 16.54 2024-04-28T10:39:20.5100000 9691 P APA 1 Test 16.544 2024-04-29T03:09:26.5100000 9672 P APA 1 Test 16.552 2024-04-30T00:31:00.2400000 9701 N Not known 16.554 2024-04-30T08:09:38.2300000 9676 N Not known 16.557 2024-04-30T17:39:41.2300000 9710 P APA 1 16.568 2024-05-02T10:39:56.9500000 9674 P APA 1 16.574 2024-05-03T07:15:27.4500000 9703 A API Endurance 16.578 2024-05-03T19:40:08.9600000 9687 P APA 1 Test 16.579 2024-05-04T18:40:16.9700000 9678 P APA 1 16.58 2024-05-05T03:15:48.4800000 9670 P APA 1 16.58 2024-05-05T09:10:21.9800000 9671 P APA 1 Test 16.58 2024-05-05T12:10:22.9900000 9702 A API Endurance 16.585 2024-05-06T12:40:31.7700000 9688 A API Endurance 16.588 2024-05-06T21:40:34.7500000 9675 p APA 1 16.598 2024-05-08T03:40:47.1000000 9679 F CR1 16.603 2024-05-08T21:00:47.3700000 9697 F CR2 16.605 2024-05-09T20:11:02.0100000 9699 S AID_ASC 16.609 2024-05-12T09:41:25.2200000 9708 S AID_ASC 16.609 2024-05-12T13:11:26.2200000 9705 P APA 2 16.612 2024-05-13T09:41:33.2200000 9693 P APA 2 16.613 2024-05-13T12:11:34.2200000 9673 P APA 2 16.616 2024-05-13T20:00:25.4700000 9704 P APA 2 16.629 2024-05-15T09:16:19.4800000 9694 F APF End Test 16.636 2024-05-16T01:45:30.5000000 9700 F APF End Test 16.643 2024-05-16T19:42:03.2600000 9682 Y YR1 16.643 2024-05-16T21:42:04.2500000 9696 Y YR2 16.649 2024-05-17T10:12:09.2500000 9690 SAS P & P + Warmtepomp 16.652 17-05-2024 21:16:15 9685 SAS HVAC EB A15 16.653 2024-05-18T16:12:19.2500000 9683 F APF Labo 16.653 2024-05-18T23:42:22.2500000 9684 SAS MT111 16.664 2024-05-22T14:01:13.1400000 9695 SAS MT112 1.5388 2024-04-30T12:39:40.2300000 9698 SAS MT110 1.5388 2024-04-30T19:09:42.2300000 9707 F APF Labo 1.5388 2024-04-30T23:39:43.2300000 9681 M HR1 1.539 2024-05-02T08:39:56.9500000 9748 SMP HR2 1.539 2024-05-02T09:09:56.9500000 9747 SMP HR3 1.5392 2024-05-02T16:39:58.9500000 9753 SMP HR4 1.5397 2024-05-04T10:40:13.9600000 9752 SMP HR8 1.5397 2024-05-04T16:10:15.9700000 9751 SMP HR11 1.5397 2024-05-05T14:40:23.9800000 9750 SMP HR12 1.5397 2024-05-05T19:10:25.9800000 9746 SMP HR14 1.5397 2024-05-06T02:40:28.9900000 9749 SMP HR12 1.5415 2024-05-09T07:40:57.1300000 9693 A API 2 1.5418 2024-05-12T18:41:28.2200000 9673 A API 2 1.542 2024-05-13T09:41:33.2200000 9680 A API 1 1.542 2024-05-13T18:11:36.2200000 9692 A API 1 1.5433 2024-05-17T17:42:11.2500000 9677 A API 1 1.5433 2024-05-18T09:42:17.2500000 9706 S BN101 1.5433 2024-05-19T19:42:29.2500000 9711 A API 1 1.5433 2024-05-20T02:42:31.2600000 9709 P BR1 1.5433 20-05-2024 11:42:35 9689 P BR2 1.5433 2024-05-20T20:12:38.0100000 9686 P APA 1 1.5448 2024-05-22T09:12:52.6400000 9691 P APA 1 Test 1.545 2024-05-22T21:42:56.6400000 9672 P APA 1 Test 3.9331 2024-04-23T08:08:36.7500000 9701 N Not known 3.9342 2024-04-24T08:08:45.7500000 9676 N Not known 3.9352 2024-04-25T15:38:56.7500000 9710 P APA 1 3.9363 2024-04-26T23:39:08.7700000 9674 P APA 1 3.9365 2024-04-27T10:39:12.5100000 9703 A API Endurance 3.9384 2024-04-30T05:09:37.2300000 9687 P APA 1 Test 3.9401 2024-05-01T23:15:16.9800000 9678 P APA 1 3.9424 2024-05-04T11:40:14.9600000 9670 P APA 1 3.9424 2024-05-04T22:40:18.9800000 9671 P APA 1 Test 3.944 2024-05-06T19:40:34.7500000 9702 A API Endurance 3.9446 2024-05-07T07:40:38.7500000 9688 A API Endurance 3.9463 2024-05-08T08:45:31.1000000 9675 p APA 1 3.9466 2024-05-08T15:10:51.1000000 9679 F CR1 3.947 2024-05-11T01:41:12.0100000 9697 F CR2 3.9497 2024-05-14T00:41:39.2300000 9699 S AID_ASC 3.9506 2024-05-14T13:11:43.2300000 9708 S AID_ASC 3.9514 2024-05-15T01:41:47.2300000 9705 P APA 2 3.954 2024-05-16T11:00:43.4800000 9693 P APA 2 3.955 2024-05-17T04:42:07.2500000 9673 P APA 2 3.9556 2024-05-17T12:42:09.2500000 9704 P APA 2 3.9559 2024-05-17T17:12:11.2500000 9694 F APF End Test 3.9563 2024-05-21T09:42:44.6300000 9700 F APF End Test 3.9575 2024-05-22T02:12:50.6400000 9682 Y YR1 3.9587 2024-05-22T18:42:55.6400000 9696 Y YR2 39.766 23-04-2024 08:31:05 9690 SAS P & P + Warmtepomp 39.766 23-04-2024 08:31:05 9685 SAS HVAC EB A15 39.777 2024-04-24T07:38:45.7500000 9683 F APF Labo 39.777 2024-04-24T07:38:45.7500000 9684 SAS MT111 39.783 2024-04-24T20:01:16.5000000 9695 SAS MT112 39.783 2024-04-24T20:01:16.5000000 9698 SAS MT110 39.787 2024-04-25T08:15:25.5000000 9707 F APF Labo 39.787 2024-04-25T08:15:25.5000000 9681 M HR1 39.792 25-04-2024 15:01:06 9748 SMP HR2 39.792 25-04-2024 15:01:06 9747 SMP HR3 39.813 2024-04-28T03:09:18.5100000 9753 SMP HR4 39.813 2024-04-28T03:09:18.5100000 9752 SMP HR8 39.816 2024-04-28T13:45:26.7600000 9751 SMP HR11 39.816 2024-04-28T13:45:26.7600000 - Bhatt23
Helper I
"group all the data according to calculation on single column"
This is the heading of the new post reagrding my problem, would be great if you can share some thoughts about new post and issues.
I am using summarized new table but still seeing issues with the result.
Anonymous