DAX create empty table with specific column names and no rows

前端 未结 3 1892
南方客
南方客 2020-12-21 21:07

How to create a table with a specified column name and no rows at all. The following oneliner does what I want but shows error message that there should be second argument i

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-21 21:39

    I would like to add to mxix answer a few useful oneliners for making one-column empty table with desired name:

    OneLiner1 = TOPN(0, ROW("Product", "Apple"))
    OneLiner2 = FILTER(ROW("Product", "Apple"), 1=2)
    

    Or if you want to define column type:

    OneLiner3 = TOPN(0, DATATABLE("Product", STRING,{{"Apple"}}) )
    

    So the snipped for bridge table is:

    Product_bridge = DISTINCT(
        UNION(
             TOPN(0, ROW("Product", "Apple"))
            ,DISTINCT(      Sales[Prod_Name]        ) 
            ,DISTINCT( Dictionary[Prod_DifferntName])
            ,DISTINCT(  PriceList[P]                )
            ))
    

提交回复
热议问题