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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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 , Try to unpivot the table in power query

https://radacad.com/pivot-and-unpivot-with-power-bi
Transpose : https://yodalearning.com/tutorials/power-query-helps-transposing-data/

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
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 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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