Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Data Reshaping ( multiple assignment to single assignment)

Hello! 🙂 I do have a table with (amongst other columns) the following data: Name Field1 Field2 Field3 Field4 Field5 abc A1 A1 E3 S2 Q1 abc S2 Fr A1 U1 I1 ... ... ... ...
  • v-cazheng-msft's avatar
    5 years ago

    Hi, Anonymous 

    You can create a Calculated column and a Measure to get the tables you want.

     

    Calculated column :

     

     

    Name_Field =

    VAR t1 =

        SELECTCOLUMNS ( 'Table', "Name", 'Table'[Name], "Field", 'Table'[Field1] )

    VAR t2 =

        SELECTCOLUMNS ( 'Table', "Name", 'Table'[Name], "Field", 'Table'[Field2] )

    VAR t3 =

        SELECTCOLUMNS ( 'Table', "Name", 'Table'[Name], "Field", 'Table'[Field3] )

    VAR t4 =

        SELECTCOLUMNS ( 'Table', "Name", 'Table'[Name], "Field", 'Table'[Field4] )

    VAR t5 =

        SELECTCOLUMNS ( 'Table', "Name", 'Table'[Name], "Field", 'Table'[Field5] )

    VAR union_t =

        UNION ( t1, t2, t3, t4, t5 )

    VAR tt =

        FILTER ( union_t, AND ( [Field] <> "", NOT ( ISBLANK ( [Field] ) ) ) )

    RETURN

        tt

     

     

    Measure :

     

     

    Count = COUNTX('Name_Field','Name_Field'[Field])

     

    The result looks like this:

    Here is the pbix file.

     

    Best Regards,

    Caiyun Zheng

     

    Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.