Relationship between tables doesn't seem to work for some values

Waimea

Active Member
Joined
Jun 30, 2018
Messages
372
Hi, I have two tables, one data table and one lookup table.

However, the lookup table doesn't seem to work for all values of the lookup table below:

Code:
[TABLE]
<tbody>[TR]
[TD]0[/TD]
[/TR]
[TR]
[TD][B]1-5[/B][/TD]
[/TR]
[TR]
[TD][B]6-15[/B][/TD]
[/TR]
[TR]
[TD]16-19[/TD]
[/TR]
[TR]
[TD]20-29[/TD]
[/TR]
[TR]
[TD]30-39[/TD]
[/TR]
[TR]
[TD]40-49[/TD]
[/TR]
[TR]
[TD]50-64[/TD]
[/TR]
[TR]
[TD]65-74[/TD]
[/TR]
[TR]
[TD]75-79[/TD]
[/TR]
[TR]
[TD]80-89[/TD]
[/TR]
[TR]
[TD]90-w[/TD]
[/TR]
</tbody>[/TABLE]
For lookup table value of 1-5 and 6-15 the relationship doesn't seem to work and the values gives me a total instead of a part of a sum. I am thinking that this could be because of sorting or something similar to that.

Is there any workaround for this?
In the image below, the 6-15 should give me 5235 and it gives me 44955 and I don't know why??


https://ibb.co/r6QQG1y

 
Last edited:

Some videos you may like

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK

Waimea

Active Member
Joined
Jun 30, 2018
Messages
372
Any suggestions on how to fix this problem? It really bothers me that I can't figure out why the lookup doesn't work!
 

Waimea

Active Member
Joined
Jun 30, 2018
Messages
372
ABC
1CityAge2017
14City (Suburb 1)01135
15City (Suburb 1)1-54395
16City (Suburb 1)6-155455
17City (Suburb 1)16-191835
18City (Suburb 1)20-2914265
19City (Suburb 1)30-3915155
20City (Suburb 1)40-498720
21City (Suburb 1)50-6410515
22City (Suburb 1)65-745105
23City (Suburb 1)75-791475
24City (Suburb 1)80-891645
25City (Suburb 1)90-w410

<tbody>
</tbody>

Column A is city name, column B is the same as my lookup table, column C is the population in that age group.

The lookup table works for age 0, 16-19, 20-29, 30-39, 40-49, 50-64, 65-74, 75-79, 80-80 and 90-w.

It doesn't work for age 1-5 and 6-15.
 
Last edited:

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,165
Could age 1-5 and 6-15 be interpreted as dates?
Change the set up like below:


<b></b><table cellpadding="2.5px" rules="all" style=";background-color: rgb(255,255,255);border: 1px solid;border-collapse: collapse; border-color: rgb(187,187,187)"><colgroup><col width="25px" style="background-color: rgb(218,231,245)" /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: rgb(218,231,245);text-align: center;color: rgb(22,17,32)"><th></th><th>A</th><th>B</th><th>C</th><th>D</th></tr></thead><tbody><tr ><td style="color: rgb(22,17,32);text-align: center;">1</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;font-style: italic;color: #333333;;">City</td><td style="font-weight: bold;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;font-style: italic;color: #333333;;">Age</td><td style="font-weight: bold;text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;font-style: italic;color: #333333;;"></td><td style="font-weight: bold;text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;font-style: italic;color: #333333;;">2017</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">14</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">0</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">1135</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">15</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">1</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">5</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">4395</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">16</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">6</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">15</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">5455</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">17</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">16</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">19</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">1835</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">18</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">20</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">29</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">14265</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">19</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">30</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">39</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">15155</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">20</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">40</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">49</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">8720</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">21</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">50</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">64</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">10515</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">22</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">65</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">74</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">5105</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">23</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">75</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">79</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">1475</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">24</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">80</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">89</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">1645</td></tr><tr ><td style="color: rgb(22,17,32);text-align: center;">25</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">City (Suburb 1)</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">90</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">w</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;color: #333333;;">410</td></tr></tbody></table><p style="width:4.8em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid rgb(187,187,187);border-top:none;text-align: center;background-color: rgb(218,231,245);color: rgb(22,17,32)">Sheet1</p>
 
Last edited:

Waimea

Active Member
Joined
Jun 30, 2018
Messages
372
Hi Aladin,

I have changed my setup as per your very clever suggestion!

I am using PowerPivot but I am unsure how to set up my lookup table?

Code:
2017 1-5:=CALCULATE([Population 2017] ;'Age'[Age] >="1" && 'Age'[Age] <="5")
 

Waimea

Active Member
Joined
Jun 30, 2018
Messages
372
I got it to work. Thank you very much Aladin!

Your suggestion is really good and clever!
 

Waimea

Active Member
Joined
Jun 30, 2018
Messages
372
If someone has the time, please show me how to set up my lookup tablesfor this set up??
 

Watch MrExcel Video

Forum statistics

Threads
1,095,541
Messages
5,445,083
Members
405,315
Latest member
ao5835403

This Week's Hot Topics

Top