英文:
Scaleable M code to create n number of columns based on the unique values in a column?
问题
我有一个充满了客户购买数据的大型数据集。有两列对我特别感兴趣:购买日期和购买订单(1表示客户的第一次购买,2表示客户的第二次购买,依此类推)。
我想为每个独特的购买订单值创建一列,并填入相应的日期。
最终结果将是针对每位客户命名的第n次购买日期的n个列。
这是目前表格的样子:
这是所期望输出的示例:
如果表格格式不清楚,我很抱歉。
我不想手动完成这个操作,因为购买订单变量是可变的。但我意识到最终可能会有太多列,所以如果可以限制列的数量,那将会很棒。
提前感谢!
我尝试过手动操作,但这很繁琐并且受限制(购买订单的最大值目前超过了60)。
英文:
I have a large dataset filled with customer purchase data. There are two columns that are of specific interest to me: the date of a purchase and the order of the purchase (1 means it was the customer's first purchase, 2 means it was the customer's second purchase, and so on).
I would like to create a column for each unique purchase order value, and fill it with the corresponding date.
The end result would be n number of columns named "1st purchase date", "2nd purchase date", [...], "n purchase date" for each customer.
This is what the table looks like currently:
This is a sample of the desired output:
Apologies if the table formatting is unclear.
I don't want to do this manually, as the purchase order variable is variable. I am however conscious of the fact that there might be too many columns in the end, so if it's possible to add a limit to the number of columns, that would be fantastic.
Thanks in advance!
I tried to do this manually, but it's arduous and limiting (the max value of the purchase order is currently >60).
答案1
得分: 0
在Power Query中,点击选择“采购订单列”。
转换...旋转列...
对于数值列,请选择日期,并在高级选项中选择“不聚合”。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论