Conditional selection of rows in power query.

6677028

New Member
Joined
Nov 19, 2022
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
I have a table of totals data. Now I want to divide the data table into many subgroups such that .
Condition: 18.5 < Total Weight < 20 and Total length < 20.
cRXeLB6.png
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Just as a prelim, are the totals here correct:
Book1
ABC
1IDWei htLen h
2A43
3D5.54
4F10.82
5H116
6G0.55
7U43
8Y52
9I6.54
10w25
11Q56
12E32
13R45
14T66
15O14
16p33
17s45
18J53
19K25
20L36
21z22
22TOTAL: 85.379
Sheet1
Cell Formulas
RangeFormula
B22:C22B22=SUM(B2:B21)

They are not. Can you tell why without the actual worksheet. No. However, this might give you a clue:
1670950003806.png

(Had to use a screenshot! XL2BB wasn't carrying the formatting properly).
Just by looking, you KNOW that the 2's in the bottom row are Text, not Numbers, and therefore need to be fixed. Doing alignment on numbers hides what is built into Excel to warn you that what might look like numbers are not. It's also better to use ROUND rather than formatting as sums can get messed up since they read the VALUES, not the visually rounded numbers.
What you want to do is to pull the table in, and then REFERENCE it 3 times.
Otherwise, I'm kind of stumped how to approach this, but look forward to seeing if someone has the answer!
 
Upvote 0
Add a column that includes a conditional column in which you build your if then else logic.
Then reference this query and filter it on that column. After filtering, remove this scenario column. Repeat for each scenario.
 
Upvote 0
Just as a prelim, are the totals here correct:
Book1
ABC
1IDWei htLen h
2A43
3D5.54
4F10.82
5H116
6G0.55
7U43
8Y52
9I6.54
10w25
11Q56
12E32
13R45
14T66
15O14
16p33
17s45
18J53
19K25
20L36
21z22
22TOTAL: 85.379
Sheet1
Cell Formulas
RangeFormula
B22:C22B22=SUM(B2:B21)

They are not. Can you tell why without the actual worksheet. No. However, this might give you a clue:
View attachment 80797
(Had to use a screenshot! XL2BB wasn't carrying the formatting properly).
Just by looking, you KNOW that the 2's in the bottom row are Text, not Numbers, and therefore need to be fixed. Doing alignment on numbers hides what is built into Excel to warn you that what might look like numbers are not. It's also better to use ROUND rather than formatting as sums can get messed up since they read the VALUES, not the visually rounded numbers.
What you want to do is to pull the table in, and then REFERENCE it 3 times.
Otherwise, I'm kind of stumped how to approach this, but look forward to seeing if someone has the answer!
Thank you,
I forgot to update.
You can see the attached file
 
Upvote 0
Thank you,
I forgot to update.
You can see the attached file
Appreciate the effort, but I don't know how to approach this. I'll think about it more, but it requires a lot of permutations (Total Weight is greater than 18.5 AND less than 20). I don't think Power Query is the answer here, but rather a well crafted Array formula. I'll see if I can come up with anything, but right now it's beyond me!
 
Upvote 0
Do forget all about my earlier reply #3. I now understand it is about selecting a set of rows which totals matches the given criteria. Like said in #5 by @jdellasala, beyond me too! Sorry for misguiding.
 
Upvote 0
Appreciate the effort, but I don't know how to approach this. I'll think about it more, but it requires a lot of permutations (Total Weight is greater than 18.5 AND less than 20). I don't think Power Query is the answer here, but rather a well crafted Array formula. I'll see if I can come up with anything, but right now it's beyond me!
That's right, it requires a lot of permutations
 
Upvote 0
Add a column that includes a conditional column in which you build your if then else logic.
Then reference this query and filter it on that column. After filtering, remove this scenario column. Repeat for each scenario.
You can do it for me. We can add extra columns. But I have no idea how to add extra column with conditional statement.
Thank!
 
Upvote 0

Forum statistics

Threads
1,223,984
Messages
6,175,785
Members
452,669
Latest member
reeseann

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top