Forum Discussion
apply calculated percent to multiple rows
Hello, I have source data with a unique order # that applies to two different unique site #'s, with each site receiving a delivered volume.
A separate source provides the line item charges associated with the order #. However, it applies the charges to only one site. The charges are broken out one row per line item.
In pbi I have relationships set-up and can show the line details and charges, but they show for each site, essentially doubling the amounts.
I have a calculated field that provides the % of volume delivered to each site and would like to apply that same % to each line item according to the order # and site #. The % is calculated by dividing the sum of volume per site by the sum of total ordered volume.
I cannot figure this out - any help is much appreciated!
| site # | order # | order_type | volume | line_details | line_net_charge |
| 2244 | 1140 | Split | 5400 | delivery charge | 1.23 |
| 2244 | 1140 | Split | product charge | 38.4 | |
| 2244 | 1140 | Split | product 2 charge | 46.08 | |
| 2244 | 1140 | Split | MINIMUM GUARANTEE | 107.52 | |
| 2244 | 1140 | Split | SOC-STOP OFF CHARGE | 119.52 | |
| 2244 | 1140 | Split | product 3 charge | 122.88 | |
| 5522 | 1140 | Split | 2800 | delivery charge | 1.23 |
| 5522 | 1140 | Split | product charge | 38.4 | |
| 5522 | 1140 | Split | product 2 charge | 46.08 | |
| 5522 | 1140 | Split | MINIMUM GUARANTEE | 107.52 | |
| 5522 | 1140 | Split | SOC-STOP OFF CHARGE | 119.52 | |
| 5522 | 1140 | Split | product 3 charge | 122.88 | |
| Total net charge of order | 435.63 | ||||
| site # | order # | order_type | volume | % split | |
| 2244 | 1140 | Split | 5400 | 66% | |
| 5522 | 1140 | Split | 2800 | 34% |
Hi ch_7 ,
Try this:
%Split = VAR __VOLUME = CALCULATE ( SUM ( 'Table1'[volume] ), FILTER ( Table1, Table1[site #] = EARLIER ( Table1[site #] ) ) ) //volume per site VAR __TOTAL_VOLUMME = SUM ( Table1[volume] ) RETURN DIVIDE ( __VOLUME, __TOTAL_VOLUMME )