多年来比较产品利润的功率查询
我有一个具有公司,产品,利润和年份的数据集。每年,公司都会出售几种产品并获得利润。该公司不必在明年出售相同的生产。它们可能被遗漏了以前的产品,并添加了新的几种产品。我只想将苹果与以下两年产品进行比较。
我的数据集是,
Company Product Profit Year
X Soap 20 2020
X Shampoo 30 2020
X Noodles 25 2021
X Shampoo 40 2021
X Coffee 60 2022
X Shampoo 34 2022
Y Coffee 20 2020
Y Noodles 30 2020
Y Shampoo 25 2021
Y Switch 40 2021
Y Soap 60 2022
Y Shampoo 34 2022
我想与每个公司的上一年的产品相比,在下面的每个公司的产品中,
t在2021年出售任何肥皂。我只想将其视为0或NULL,并想改变下面的桌子。在电源查询中有什么方法可以做到这一点?
I have a dataset which having Company, Product, Profit and Year. Each year the company will sell few products and obtain the profits. Its not necessary the company should sale the same production in the next year. They may be left out previous products and add new few productions. I just want to apple to apple comparison of two year products like below.
My dataset is,
Company Product Profit Year
X Soap 20 2020
X Shampoo 30 2020
X Noodles 25 2021
X Shampoo 40 2021
X Coffee 60 2022
X Shampoo 34 2022
Y Coffee 20 2020
Y Noodles 30 2020
Y Shampoo 25 2021
Y Switch 40 2021
Y Soap 60 2022
Y Shampoo 34 2022
I wanted to transform the table compared with the previous year's product for each respective year of every company like below,
Look at the above, the company didn't sell any soap in the year 2021. I just want to consider it as 0 or null and wanted to transform the table like below. Is there any way to do this in the Power query?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一种方法。
我今天晚上没有时间进行详细的解释,但是如果您阅读M代码和评论;并且还遵循应用步骤,您应该能够弄清楚它。
基础知识
键
m代码
Here's one method.
I don't have time this evening to do a detailed explanation, but if you read the M Code and comments; and also follow along the Applied Steps, you should be able to figure it out.
Basics
Key
M Code