Power Query to sum for each color and each size, return a value on the available size list - excel

I have a list of shirt colors and the suggested sizes of them. I would like to create a new column in the query and have a value of list based on the filtered elements ( I have no idea how to explain it differently, feel free to correct me). So the rules are:
If the current color has XS in the occurrence list then the value of the row needs to be "YES"
If the current color does not have XS but has XXL,XL or L then the value should be "XYES"
Otherwise the value needs to be "NO"
Jacket Color
Jacket Size
Black
XS
Black
XS
Black
S
Blue
XS
Blue
L
Blue
XL
Blue
XXL
Blue
XL
Blue
XXL
Green
XS
Green
S
Green
M
Red
XS
Red
XXL
Red
S
Red
XXL
White
S
White
M
The table should look like this:
Jacket Color
Jacket Size
New_col
Black
XS
YES
Black
XS
YES
Black
S
YES
Blue
XS
XYES
Blue
L
XYES
Blue
XL
XYES
Blue
XXL
XYES
Blue
XL
XYES
Blue
XXL
XYES
Green
XS
YES
Green
S
YES
Green
M
YES
Red
XS
XYES
Red
XXL
XYES
Red
S
XYES
Red
XXL
XYES
White
S
NO
White
M
NO
I am not that big of a tech guy myself, if you can help me how to google the answer, that is good aswell.Thank you in advance.
Tried everything I could with this little knowledge I have about power query. If this could be solved by me, I would have a job right now.

Your result data doesn't match your sample data but this is the process.
Import data in PQ
Select Jacket Color and then group by from the ribbon. Enter the following:
Add a new custom column from the ribbon and enter the following:
if List.Contains([All][Jacket Size], "XS") then "Yes" else if List.ContainsAny([All][Jacket Size], {"XXL","XL", "L"}) then "XYES" else "No"
Expand the column to get all rows back.

Related

change the color and make bold the result in excel formula

How do I make the color of result "&O4&" green and the color of the result of "&P4&" red?
Here is the formula: ="Present: "&" "&O4&" Times"&" "&" Absent:"&" "&P4&" Times"
Here is the result: Present: 4 Times Absent: 0 Times
I want 4 to be green and 0 to be red in color and bold

Double dependency dropdownlist in excel

I have excel worksheet with :
three columns A, B, C with coloured animals:
cell D1 with dropdownlist with values: cat, dog, elephant, rabbit, lion
cell E1 with dropdownlist with values: yellow, red, white
Example data are like below:
A B C
---------------------------------------------------------
1 | cat yellow my loved yellow cat
1 | cat yellow my hated yellow cat
2 | cat red my favourite red cat
3 | dog white ugly white dog
4 | dog white elegant white dog
5 | elephant white beauty white elephant
6 | elephant yellow tiny yellow elephant
7 | rabbit red small red rabbit
8 | lion red red lion for my son
9 | lion white my pet lion white
Now in cell F1 I need to have the dropdown list dependent on values selected in cells in D1 and E1. So If you will select in D1 cat and in E1 yellow, you should have in F1 two options to select:
my loved yellow cat
my hated yellow cat
The solutions with one dependent column I do it:
Data -> Validation -> List -> in formula I paste:
=OFFSET($C$1,MATCH(D1,$A$1:$A$9,0)-1,0,COUNTIF($A$1:$A$9,D1),1)
But this filter only by animals and I have in dropdown three cats: my loved yellow cat, my hated yellow cat, my favourite red cat. But I need only yellow cats! Is method to create it like desctibed below?
Have a look here, there something very similar.
I think this is what you are looking for:
=IFERROR(INDEX(C1:C10, SMALL(IF(1=((--(D1=A1:A10))*(--(E1=B1:B10))), ROW(C1:C10),""), ROW())),"")

Changing the color of agents in NetLogo according to a turtle-own variable

I am writing a simple food exchange model in netlogo and I want the agents to change their color as their [food] level changes in the model. The amount of food is in range [0,1] and I want the color to change from white to red (white = food level of zero and red = food level of 1) with the code below:
ask turtles [
set color scale-color red food 1 0 ]
But my turtles turn black somehow in the middle of food exchange! Turtles own food value can be any floating point number in the range [0,1]. Does anyone know how I can keep the color within the light shades of red (red to white) and no black?
Scale-color and ranges
From the example above, the color and number are correct, but the issue seems to be with the range provided. Since food is within [0,1], the color gradient should match the changes, though it will be from 0 (white) to 1 (black).
As JenB mentioned, you might want to extend the range of the expected values. Changing the range from [0,1] to [0,2] for scale-color would help, since with scale-color the midpoint of the range is the color provided.
[ set color scale-color red food 2 0 ]
As long as food is within [0,1], this example should fluctuate between red and white.

Excel - Overlapping Data - Pivottable

Is it possible to create a table for data with overlapping values within the same column?
I would prefer a pivot table where I could slice the data instead of Venn Diagram.
Data
1. Red / Material 1
2. Red / Material 2
3. Red / Material 3
4. Red / Material 4
5. Red / Material 5
6. Blue / Material 1
7. Blue / Material 6
8. Blue / Material 7
9. Blue / Material 8
10. Blue / Material 9
11. Blue / Material 10
12. Blue / Material 11
13. Blue / Material 12
14. Green / Material 1
15. Green / Material 2
16. Green / Material 6
17. Green / Material 7
18. Green / Material 8
19. Green / Material 13
20. Green / Material 14
First, create a table that has combinations of colors like this:
Color Color2
-------------
Red Red
Red Blue
Red Green
Blue Red
Blue Blue
Blue Green
Green Red
Green Blue
Green Green
One way to do this is to created a calculated Colors table like this:
Colors = CROSSJOIN(SELECTCOLUMNS(VALUES(Data[Color]), "Color", Data[Color]),
SELECTCOLUMNS(VALUES(Data[Color]), "Color2", Data[Color]))
Now we can create a calculated column on this table that counts the intersecting values:
Count =
VAR Materials1 = CALCULATETABLE(VALUES(Data[Material]),
Data[Color] = EARLIER(Colors[Color]))
VAR Materials2 = CALCULATETABLE(VALUES(Data[Material]),
Data[Color] = EARLIER(Colors[Color2]))
RETURN IF(Colors[Color] = Colors[Color2], BLANK(),
COUNTROWS(INTERSECT(Materials1, Materials2)))
Now you can set them up in a matrix visual with Color on the Rows and Color2 on the Columns and Count in the Values box.

How to extract a particular word from a cell in excel that matches a list of values

How to extract a particular word from a cell in excel from a list (array) of possible values and return that matched word.
I have a list of products, but I just want to know the color. The color is embedded in the products description, therefore I need to extract it out of the item description. Here is a brief example of a list the item descriptions:
CORNER CCP 26" BARN RED
CORNER CCP 28" KHAKI
CORNER CCP 28" SLATE GRAY
CORNER RS EZ ANTIQUE GRAY
CORNER RS EZ 26" ASHWOOD GRAY
CORNER,RSC EZ,AUTUMN CEDAR
CORNER RS EZ 26" BARN RED
CORNER RS EZ 26" CANARY YELLOW
CORNER RS EZ 26" COASTAL BROWN
CORNER,RS EZ 26" COASTAL CLAY
CORNER,RS EZ 26"COASTAL CEDAR
CORNER RS EZ 26" CYPRESS GREEN
CORNER RS EZ 26" CLASSIC WHIT
I want to then compare that Item description with a list of colors I have and then just return those color names.
Amaranth
Amber
Amethyst
Apricot
Aquamarine
Azure
Baby blue
Beige
Black
Blue
Blue-green
Blue-violet
Blush
Bronze
Brown
Burgundy
Byzantium
Carmine
Cerise
Cerulean
Champagne
Chartreuse green
Chocolate
Cobalt blue
Coffee
Copper
Coral
Crimson
Cyan
Desert sand
Electric blue
Emerald
Erin
Gold
Gray
Green
Harlequin
Indigo
Ivory
Jade
Jungle green
Lavender
Lemon
Lilac
Lime
Magenta
Magenta rose
Maroon
Mauve
Navy blue
Ocher
Olive
Orange
Orange-red
Orchid
Peach
Pear
Periwinkle
Persian blue
Pink
Plum
Prussian blue
Puce
Purple
Raspberry
Red
Red-violet
Rose
Ruby
Salmon
Sangria
Sapphire
Scarlet
Silver
Slate gray
Spring bud
Spring green
Tan
Taupe
Teal
Turquoise
Violet
Viridian
White
Yankees Blue
Yellow
Place the data in column A.
Place the list of colors in column B.
Place the following array formula in column C and fill down:
=IFERROR(INDEX($B$1:$B$86,MATCH(1,COUNTIF($A1,"*"&$B$1:$B$86&"*"),0)),"")
Note that this is an array formula. In order for it to operate correctly, first copy and paste from your browser window to Excel, then, with the same cell selected, click in the formula bar (or press F2) and press Control + Shift + Enter. There should now be braces around the formula.
If the string in column A contains more than one of the colors in column B, the first matching column B color will be listed.

Resources