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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Attribute Value (summing up columns after unpivoting them)

Hello Community, I have an Excel sheet that I am bringing into Power Bi.   The Excel sheet has about 50 columns that cover different inspection criteria, and about 100 rows (of different items).   Each item is one row.   

 

After bringing into Power Bi, I unpivoted the inspection columns.  So now, all of the inspection criteria are in one column, and the Pass/Fail is in another column.   What I am trying to do now is to create a measure that sums up all of the "P"  and all of the "F" for each particular attribute.   Just not sure how to go about how to go about it.  With the goal of having a matrix that could look like this: 

 

                    Inspection Criteria 1      Inspection Criteria 2       Inspection Criteria 3    Etc...

Pass                 98                                           97                                    89

Fail                   2                                             3                                      11

 

This is the Excel layout  (there are many rows of items...each item is one row)

 

texmexdragon_0-1632314612776.png

    

To the left of the columns below is another column called Item.    I unpivoted the columns above, to get all of the attributes in column, and the Pass / Fail in another column

 

texmexdragon_1-1632314696974.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

There's no need to create a measure once you have this table unpivoted. You only need to create a matrix visual!

See image below on how should be built and I leave you a sample file you can leverage from. (I simulated your table entering data manually)

Note: You can have the matrix structured 2 ways. I would suggest you the one of the left since you mention you have a lot of inspection criteria.

Raymundo2910_1-1632317990812.png

 

Raymundo2910_0-1632317878004.png

File Here 

View solution in original post

15 REPLIES 15
Anonymous
Not applicable

There's no need to create a measure once you have this table unpivoted. You only need to create a matrix visual!

See image below on how should be built and I leave you a sample file you can leverage from. (I simulated your table entering data manually)

Note: You can have the matrix structured 2 ways. I would suggest you the one of the left since you mention you have a lot of inspection criteria.

Raymundo2910_1-1632317990812.png

 

Raymundo2910_0-1632317878004.png

File Here 

Anonymous
Not applicable

@Anonymous   Thanks Ray...I am giving your option a try as well!     Will report back and give kudos to both once I can successfully confirm the solution.   Working on it now!

c781d
Regular Visitor

Hi @Anonymous 

 

If I unerstand your problem, you have this

c781d_0-1632317482531.png

 

And is this your goal?

c781d_1-1632317551522.png

 

Anonymous
Not applicable

Yes, exactly! 

Nice!

 

Paste this step on your queryeditor

 

= Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[atribute]), "atribute", "item", List.Count)

 

c781d_0-1632318036901.png

 

 

Regards!

Anonymous
Not applicable

Which step in the query?   

texmexdragon_0-1632318487333.png

 

Please, Replace your last two lines with:

 

#"Pivoted Column" = Table.Pivot(#"Unpivoted Columns", List.Distinct(#"Changed Type"[atribute]), "atribute", "item", List.Count)
in
#"Pivoted Column"

 

c781d_0-1632318849786.png

 

 

 

Make sure that the #"Unpivoted Colums" line fishes with comma

Anonymous
Not applicable

Hmmm...I am getting an error message.   Saying the column Attribute of the table was not found?

 

texmexdragon_0-1632319633045.png

 

Sorry, I forgot to tell you to change also the second #"Changed Type".

 

Please, change the #"Changed Type" into List.Distinct for #"Unpivoted Columns".

 

#"Pivoted Column" = Table.Pivot(#"Unpivoted Columns", List.Distinct(#"Unpivoted Columns"[Attribute]), "Attribute", "Item", List.Count)
in
#"Pivoted Column"

 

It should work now

Anonymous
Not applicable

Hey @c781d  Now I am not getting an Attribute column, but did successfully load the model.   Are you available for a quick consultation (not free of course!) 

Anonymous
Not applicable

Here is how my value column now looks after apply the m code.   It contains both a numeric value and a P  or  F  value....so something is not quite right

 

texmexdragon_0-1632322813643.png

 

Could you please share your file with me?

In thatt way I could back to you with the solution

 

Thanks

Anonymous
Not applicable

Unfortunately I cannot share the file.   Actually, the solution provided by @Anonymous  worked and he was right, I did not need to do any further edits to the query editor after I did the initial unpivot.    I could see where your solution might have eventually worked as well, but it was giving me strange results.   

Glad to help you.

 

Yes, ask what ever you want. Lets see if i can get it

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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