I am having trouble building a measure to accomplish what's described below.
I am working with the following scenario:
- There are 2 types of balls: green and red.
- There are 3 types of buckets: A, B and C.
The balls are randomly dropped inside the buckets. The table below shows how many balls are inside each bucket:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD="align: center"]Bucket-A[/TD]
[TD="align: center"]Bucket-B[/TD]
[TD="align: center"]Bucket-C[/TD]
[TD="align: center"]Total[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]6[/TD]
[/TR]
</tbody>[/TABLE]
Now, the table below shows how many balls, by color, should be removed from the buckets:
[TABLE="class: grid, width: 100, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD="align: center"]Remove[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: center"]3[/TD]
[/TR]
</tbody>[/TABLE]
The balls should be removed from the buckets starting from the lowest ranked bucket for each ball color.
Below is the rank of each bucket by ball color:
[TABLE="class: grid, width: 300, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD="align: center"]Bucket-A[/TD]
[TD="align: center"]Bucket-B[/TD]
[TD="align: center"]Bucket-C[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]3[/TD]
[/TR]
</tbody>[/TABLE]
The table below shows how the final result looks like after the balls are removed starting from the lowest ranked buckets:[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD="align: center"]Bucket-A[/TD]
[TD="align: center"]Bucket-B[/TD]
[TD="align: center"]Bucket-C[/TD]
[TD="align: center"]Total[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]3[/TD]
[/TR]
</tbody>[/TABLE]
Explaining the case of the green ball: the Bucket-A is ranked lowest (rank = 3) among the 3 buckets and the quantity in the Bucket-A dropped from 1 to 0. Then the Bucket-B (rank = 2) had its quantity lowered from 2 to 1. Result: total of 2 green balls removed.
Question: Is it possible to build a measure to give me the results showing in the table above? Basically I need a measure to calculate the quantity of balls to be removed from each bucket according to their rankings by ball color.
------------------------------------
These are the tables I am working with:
Table: Remove
[TABLE="class: grid, width: 100, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD="align: center"]Remove[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: center"]3[/TD]
[/TR]
</tbody>[/TABLE]
Table: Quantity
[TABLE="class: grid, width: 300, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD]Bucket_ID[/TD]
[TD]Line_ID[/TD]
[TD="align: center"]Quantity[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-A[/TD]
[TD]Green-A[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-B[/TD]
[TD]Green-B[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-C[/TD]
[TD]Green-C[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-A[/TD]
[TD]Red-A[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-B[/TD]
[TD]Red-B[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-C[/TD]
[TD]Red-C[/TD]
[TD="align: center"]1[/TD]
[/TR]
</tbody>[/TABLE]
Table: Rank
[TABLE="class: grid, width: 300, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD]Bucket_ID[/TD]
[TD]Line_ID[/TD]
[TD="align: center"]Rank[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-A[/TD]
[TD]Green-A[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-B[/TD]
[TD]Green-B[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-C[/TD]
[TD]Green-C[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-A[/TD]
[TD]Red-A[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-B[/TD]
[TD]Red-B[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-C[/TD]
[TD]Red-C[/TD]
[TD="align: center"]3[/TD]
[/TR]
</tbody>[/TABLE]
The tables "Remove" and "Quantity" are linked by the column "Ball_color".
The tables "Quantity" and "Rank" are linked by the column "Line_ID".
Any help is appreciated. Thanks.
I am working with the following scenario:
- There are 2 types of balls: green and red.
- There are 3 types of buckets: A, B and C.
The balls are randomly dropped inside the buckets. The table below shows how many balls are inside each bucket:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD="align: center"]Bucket-A[/TD]
[TD="align: center"]Bucket-B[/TD]
[TD="align: center"]Bucket-C[/TD]
[TD="align: center"]Total[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]4[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]6[/TD]
[/TR]
</tbody>[/TABLE]
Now, the table below shows how many balls, by color, should be removed from the buckets:
[TABLE="class: grid, width: 100, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD="align: center"]Remove[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: center"]3[/TD]
[/TR]
</tbody>[/TABLE]
The balls should be removed from the buckets starting from the lowest ranked bucket for each ball color.
Below is the rank of each bucket by ball color:
[TABLE="class: grid, width: 300, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD="align: center"]Bucket-A[/TD]
[TD="align: center"]Bucket-B[/TD]
[TD="align: center"]Bucket-C[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: center"]3[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]3[/TD]
[/TR]
</tbody>[/TABLE]
The table below shows how the final result looks like after the balls are removed starting from the lowest ranked buckets:[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD="align: center"]Bucket-A[/TD]
[TD="align: center"]Bucket-B[/TD]
[TD="align: center"]Bucket-C[/TD]
[TD="align: center"]Total[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: center"]2[/TD]
[TD="align: center"]1[/TD]
[TD="align: center"]0[/TD]
[TD="align: center"]3[/TD]
[/TR]
</tbody>[/TABLE]
Explaining the case of the green ball: the Bucket-A is ranked lowest (rank = 3) among the 3 buckets and the quantity in the Bucket-A dropped from 1 to 0. Then the Bucket-B (rank = 2) had its quantity lowered from 2 to 1. Result: total of 2 green balls removed.
Question: Is it possible to build a measure to give me the results showing in the table above? Basically I need a measure to calculate the quantity of balls to be removed from each bucket according to their rankings by ball color.
------------------------------------
These are the tables I am working with:
Table: Remove
[TABLE="class: grid, width: 100, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD="align: center"]Remove[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD="align: center"]3[/TD]
[/TR]
</tbody>[/TABLE]
Table: Quantity
[TABLE="class: grid, width: 300, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD]Bucket_ID[/TD]
[TD]Line_ID[/TD]
[TD="align: center"]Quantity[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-A[/TD]
[TD]Green-A[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-B[/TD]
[TD]Green-B[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-C[/TD]
[TD]Green-C[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-A[/TD]
[TD]Red-A[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-B[/TD]
[TD]Red-B[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-C[/TD]
[TD]Red-C[/TD]
[TD="align: center"]1[/TD]
[/TR]
</tbody>[/TABLE]
Table: Rank
[TABLE="class: grid, width: 300, align: left"]
<tbody>[TR]
[TD]Ball_color[/TD]
[TD]Bucket_ID[/TD]
[TD]Line_ID[/TD]
[TD="align: center"]Rank[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-A[/TD]
[TD]Green-A[/TD]
[TD="align: center"]3[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-B[/TD]
[TD]Green-B[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Green[/TD]
[TD]Bucket-C[/TD]
[TD]Green-C[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-A[/TD]
[TD]Red-A[/TD]
[TD="align: center"]1[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-B[/TD]
[TD]Red-B[/TD]
[TD="align: center"]2[/TD]
[/TR]
[TR]
[TD]Red[/TD]
[TD]Bucket-C[/TD]
[TD]Red-C[/TD]
[TD="align: center"]3[/TD]
[/TR]
</tbody>[/TABLE]
The tables "Remove" and "Quantity" are linked by the column "Ball_color".
The tables "Quantity" and "Rank" are linked by the column "Line_ID".
Any help is appreciated. Thanks.