admin管理员组文章数量:1277361
I am annually tracking the names of car models, which may or may not change each year (its random).
Suppose I start with three models in 2023 that all changes name in 2024 and 2025, thus producing the columns "Year", "Old_name", and "New_name" in the dataset below. E.g., a model is renamed from "H" to "I" in 2024, then renamed from "I" to "J" in 2025, and finally from "J" to "K" in 2025 ("H" through "K" is thus the same model).
I would like to produce a calculated column ("Naming_group") that tracks the change over time, and then gives it the newest name that the model currently has. E.g., "K" is returned for the model that was once called "H", "I", and "J".
My dataset is fairly small, so this is the only table that is in the dashboard.
Unfortunately, I do not have much DAX code to show that I have tried to solve it myself up to this point.
Year | Old_name | New_name | Naming_group |
---|---|---|---|
2023 | A | A | C |
2023 | H | I | K |
2023 | V | X | Z |
2024 | A | B | C |
2024 | I | J | K |
2024 | X | Y | Z |
2025 | B | C | C |
2025 | J | K | K |
2025 | Y | Z | Z |
I am annually tracking the names of car models, which may or may not change each year (its random).
Suppose I start with three models in 2023 that all changes name in 2024 and 2025, thus producing the columns "Year", "Old_name", and "New_name" in the dataset below. E.g., a model is renamed from "H" to "I" in 2024, then renamed from "I" to "J" in 2025, and finally from "J" to "K" in 2025 ("H" through "K" is thus the same model).
I would like to produce a calculated column ("Naming_group") that tracks the change over time, and then gives it the newest name that the model currently has. E.g., "K" is returned for the model that was once called "H", "I", and "J".
My dataset is fairly small, so this is the only table that is in the dashboard.
Unfortunately, I do not have much DAX code to show that I have tried to solve it myself up to this point.
Year | Old_name | New_name | Naming_group |
---|---|---|---|
2023 | A | A | C |
2023 | H | I | K |
2023 | V | X | Z |
2024 | A | B | C |
2024 | I | J | K |
2024 | X | Y | Z |
2025 | B | C | C |
2025 | J | K | K |
2025 | Y | Z | Z |
Thank you in advance!
Edit: it should be noted that a model does not necessarily change its name from year to year.
Share Improve this question edited Feb 27 at 9:35 Andreas asked Feb 24 at 6:11 AndreasAndreas 1532 silver badges9 bronze badges1 Answer
Reset to default 1updated the answer
try to use PQ to create a new table
let Source = Table.SelectRows(Table,each [Old_name]<>[New_name]), #"Removed Columns" = Table.RemoveColumns(Source,{"Year"}), #"Appended Query" = Table.Combine({#"Removed Columns",Table.RenameColumns(Table.FromList(Table.SelectRows(Table,each [Year]=List.Max(Table[Year]))[New_name]),{{"Column1","Old_name"}})}) in #"Appended Query"
use DAX to create columns in the new table
Column = path('Table (2)'[Old_name],'Table (2)'[New_name])
Column 2 = left([Column],1)
create a new column in your original table
group = MAXX ( FILTER ( 'Table (2)', 'Table (2)'[Old_name] = 'Table'[Old_name] ), [Column 2] )
本文标签: powerbiTracking variable name changes within group in Power BIStack Overflow
版权声明:本文标题:powerbi - Tracking variable name changes within group in Power BI - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741290755a2370533.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论