模型数据源-Power BI

时间:2019-04-29 13:30:44

标签: powerbi dax powerquery m

我正在尝试在Power Bi中为数据源建模,但我没有得到它。

您能帮我替代方法,以便我创建一个新列吗?数据源在excel中,并按类型(XPTO,XPT等)将数据汇总。我想将这些类型作为对应的值放在项目的新列中。我尝试通过功率查询和dax进行尝试,但不能。

原始资料来源: Original Source

需要修改 Modifications Needed

Source File

2 个答案:

答案 0 :(得分:0)

这假定您可以通过检查第一列中第一个空格的位置来标识小计行:

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Added RowType" = Table.AddColumn(Source, "RowType", each Text.PositionOf([#"Centro financ./item orçamento"]," "), Int64.Type),
    #"Added Type" = Table.AddColumn(#"Added RowType", "Type", each if [RowType] = 4 then Text.BetweenDelimiters([#"Centro financ./item orçamento"], "  ", " ") else null, type text),
    #"Filled Down" = Table.FillDown(#"Added Type",{"Type"}),
    #"Filtered Rows" = Table.SelectRows(#"Filled Down", each ([RowType] = 8)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"RowType"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Removed Columns",List.Combine({{"Type"}, Table.ColumnNames(Source)}))
in
    #"Reordered Columns"

答案 1 :(得分:0)

另一种解决方案是-在Power BI中包括另一个数据源,看起来像这样。

Item                  Type
615x92120 Mat1        XPTA
615x92121 Mat2        XPTA
615x92122 Mat3        XPTU
615x92123 Mat4        XPTU

然后在现有表和该表之间进行联接,以在现有表中显示Type。完成此操作后,您应该可以将其过滤为空或为空,这将是您的删除行。

注意:-仅当您事先知道所有项目和相应类型时,此方法才有效。

相关问题