Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

Data Reshaping ( multiple assignment to single assignment)

Hello! 🙂
I do have a table with (amongst other columns) the following data:

NameField1Field2Field3Field4Field5
abcA1A1E3S2Q1
abcS2FrA1U1I1
..................
defA2D3 F3S2
defC2A4F3  
..................

Notes:
There are more then two names

Field 1-5 are next to each other, "Name" is further away

Field1-5 only includes one value per cell which consists of a number and a letter

I try to get/need:

T1:

NameField
abcA1
abcA1
... 
defA2
 D3
......


and

T2:

NameFieldCount
abcA13
.........
defF32
.........


Verbally spoken: I need a 1:1 assigment of name:field and also, how often a certain field occurs, regardless the Field (1-5) and the row of T1, only in dependence of the name  (so for example A1 occurs in T1 in row 1 (abc) 2x, in row 2 (abc) 1x -> abc A1 3
I only have Power BI as tool aviable and I am completly new to it. So it would be lovely, if someone could help me out! 🙂

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi, @Anonymous 

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

 

Calculated column :

v-cazheng-msft_0-1613119406165.png

 

 

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 :

v-cazheng-msft_1-1613119406168.png

 

 

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

 

The result looks like this:

v-cazheng-msft_2-1613119406170.png

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.

 

 

View solution in original post

3 REPLIES 3
v-cazheng-msft
Community Support
Community Support

Hi, @Anonymous 

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

 

Calculated column :

v-cazheng-msft_0-1613119406165.png

 

 

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 :

v-cazheng-msft_1-1613119406168.png

 

 

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

 

The result looks like this:

v-cazheng-msft_2-1613119406170.png

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.

 

 

amitchandak
Super User
Super User

Anonymous
Not applicable

Hello @amitchandak 
Thank you for your reply. The data is not pivoted from the beginning on, the base table is just a flat data structure. Do you know how I can work with your solution then?

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors