简体   繁体   English

将Excel Power查询表列转换为字符串

[英]Convert Excel power query table column to string

I am trying to make my power query more dynamic, currently I request my data using a stored procedure including part-no parameter that I hard-code into my query 我正在尝试使功率查询更动态,目前,我使用存储过程来请求数据,其中包括部分编码为硬编码到查询中的参数

EXEC GSCM_Staging.dbo.top_N_BOM 
    @Top_Parts = 'GL158K380G03|GL302K479G02|GL825R339G06|GL825R367G03|GL212R585G06'

I already have the individual part numbers in a list from a table in Excel 我已经在Excel表格的列表中拥有单个零件号

在此处输入图片说明

How would I go about converting this column with 4 rows into a column with a single pipe delimited row (Like the one used in my SQL query) 我该如何将具有4行的该列转换为具有单个管道分隔行的列(就像在SQL查询中使用的那样)

Fairly easy 相当容易

Beginning from your Source table 从您的Source表开始

  1. first convert the table to list 首先将表转换为列表

     ListOfParts = Source[TOP_PART] 
  2. then concatenate the list into delimited text 然后将列表连接成定界文本

     JoinedText = Text.Combine(ListOfParts, "|") 
  3. further modify it if required 如有需要,进一步修改

     PartsFilter = "'" & JoinedText "'" 

In short 简而言之

let
    Source = Table.CurrentWorkbook.....
    ListOfParts = Source[TOP_PART]
    JoinedText = Text.Combine(ListOfParts, "|")
    PartsFilter = "'" & JoinedText "'"
in PartsFilter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM