Forum Discussion
creating a key based on another column's value
- 4 years ago
Hi Anonymous
You are close to what you want. When you merge two queries and get the Control column, click Expand icon and select LeftDigits column as you did in the image. Then click OK to expand it. You will have LeftDigits column added to this table. Just like below.
Then add a custom column and enter below code into the popup window. Note that you need to transform Zipcode column to Text type in advance for it to be used in the Text.Start function. Finally you will get the Key column.
[Country] & "-" & Text.Start([Zipcode],if [LeftDigits] is null then 0 else [LeftDigits])Regards,
Community Support Team _ Jing
Create a control table with one row per country and 2 columns:
- Country
- LeftDigits
Merge the control table and the fact table on Country.
Add a custom column = Text.Start([Zipcode],if [LeftDigits] is null then 0 else [LeftDigits])
When you say "merge" the 2 tables did you mean "merge query"? when I created the "merged query" i linked the Country in my Control table with the "Ship to zip country". When I did this, it created a column called "Control". And then when I used the formula Text.Start([Zipcode],if [LeftDigits] is null then 0 else [LeftDigits]) it does not work. Am I missing a step somewhere? Thanks.