【发布时间】:2021-11-11 17:08:31
【问题描述】:
我一直在努力提高查询的灵活性。
我有事实表:
| enabled | country | color | count | vehicle |
|---|---|---|---|---|
| yes | DE | yellow | one | car |
| no | FR | blue | one | car |
| no | DE | red | one | bike |
| yes | DE | green | one | car |
| yes | ES | yellow | one | car |
| yes | IT | yellow | two | car |
| yes | IT | yellow | one | car |
在 Excel 中我还想要两个简单的配置表:
- 表:RemoveRecordsByValue 包含字段-值对的表,如果有任何匹配项,则作为删除这些记录的条件。
| field | value |
|---|---|
| vehicle | bike |
| color | green |
| color | red |
- 表:KeepRecordsByValue 一张桌子,可能
| field | value |
|---|---|
| country | DE |
| country | IT |
| count | one |
预期的表格是:
| enabled | country | color | count | vehicle |
|---|---|---|---|---|
| yes | DE | yellow | one | car |
| yes | IT | yellow | one | car |
任何人都可能有提示如何解决这个问题?
提前致谢,
***FactsTable***
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WqkwtVtJRcnEFEpWpOTn55UBGfl4qkExOLFKK1YlWyssHctyCgERSTmkqdmmw/qLUFLhsUmZ2Klgayfz0otTUPAz9EAWuwbgdAFHhGYKsoqQ8n4AKJDNiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [enabled = _t, country = _t, color = _t, count = _t, vehicle = _t]),
Result = Table.TransformColumnTypes(Source,{{"enabled", type text}, {"country", type text}, {"color", type text}, {"count", type text}, {"vehicle", type text}})
in
Result
***RemoveRecordsByValue***
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WKkvNyEzOSVXSUUrKzE5VitWJVkrOz8kvAgqkF6Wm5qGIFKWmKMXGAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [field = _t, value = _t]),
Result = Table.TransformColumnTypes(Source,{{"field", type text}, {"value", type text}})
in
Result
***KeepRecordsByValue***
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSs4vzSspqlTSUXJxVYrVQRbwDEEIALn5ealKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [field = _t, value = _t]),
Result = Table.TransformColumnTypes(Source,{{"field", type text}, {"value", type text}})
in
Result
´´´
【问题讨论】:
标签: powerbi dax powerquery m