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
phumengam
Regular Visitor

Create a new table from the average value of each columns

Hi All,

 

I am trying to create a new table to display on the report where each row consists of column name and the average value of that column. See the pic, https://ibb.co/hcRTkg5

 

My original data would look something like this:

 

Factor 1 | Factor 2 | Factor 3

-------------------------------

      1      |        2     |       4     |

      9      |        6     |       3     |

      1      |        7     |       1     | 

 

 

The output table that I am looking for would look like this:

Factors |  Scores |

-------------------

Factor1 | Average(Factor1) |

Factor2 | Average(Factor2) |

Factor3 | Average(Factor3) |

 

 

I followed this link: https://community.powerbi.com/t5/Desktop/Create-table-from-measures/m-p/275686 but it doesn't seem to work.  Here is my code: 

````

Table =
UNION(ROW("Factor","Factors","Score", "Scores")
, ROW("Factor","Factor1","Score", [avg_1])
, ROW("Factor","Factor2","Score", [avg_2])
, ROW("Factor","Factor3","Score", [avg_3]))

```

This is the error message I received: "the expression refers to multiple columns. multiple columns cannot be converted to a scalar value"

 

Thanks.

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@phumengam , Try like given below

 

Table =
UNION(
ROW("Factor","Factor1","Score", [avg_1])
, ROW("Factor","Factor2","Score", [avg_2])
, ROW("Factor","Factor3","Score", [avg_3]))

 

 

Have you explored option, "Show on Row" in Matrix, which can show measure on row

https://www.burningsuit.co.uk/blog/2019/04/7-secrets-of-the-matrix-visual/

 

Another option is to unpivot or transpose the table 

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

View solution in original post

You should create a new table instead of a new column in order for this code to work.

 

FarhanAhmed_0-1611556327551.png

 







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




View solution in original post

8 REPLIES 8
FarhanAhmed
Community Champion
Community Champion

Try This to create new table.

 

Table = 
UNION(
 ROW("Factor","Factor1","Score", AVERAGE(Factor[Factor 1 ]))
, ROW("Factor","Factor2","Score", AVERAGE(Factor[ Factor 2 ]))
, ROW("Factor","Factor3","Score", AVERAGE(Factor[ Factor 3])))

  







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




Do you by any chance know if we can make the filter work with this table measure?

 

All data (no filter):

phumengam_0-1611614794463.png

Applying a filter: The filter is working with card but it doesn't work with the measure table. 

phumengam_1-1611614808384.png

 

Do you know if we can apply the filter on this table?

 

 

I received the same error.

phumengam_0-1611553332957.png

Note that my table is called "ee_Data modeling_result" and the columns are called score_v1, score_v2,...

 

Here is what my sample data looks like: 

phumengam_1-1611553506511.png

 

 

You should create a new table instead of a new column in order for this code to work.

 

FarhanAhmed_0-1611556327551.png

 







Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!

Proud to be a Super User!




This works!  I have spent quite a few hours on this.  Thanks a lot, @FarhanAhmed.

amitchandak
Super User
Super User

@phumengam , Try like given below

 

Table =
UNION(
ROW("Factor","Factor1","Score", [avg_1])
, ROW("Factor","Factor2","Score", [avg_2])
, ROW("Factor","Factor3","Score", [avg_3]))

 

 

Have you explored option, "Show on Row" in Matrix, which can show measure on row

https://www.burningsuit.co.uk/blog/2019/04/7-secrets-of-the-matrix-visual/

 

Another option is to unpivot or transpose the table 

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

Thank for your response. 

 

1. When I tried the code, I received the same error. 

 

2. I'm not sure how can I leverage the "Show on Row". I think that I still need to construct a table of summary statistic first then I can do the "Show on Row".

 

3. I was thinking about pivoting the data but I have other visualization objects that relies on the same data. So, is it possible to create seperate pivot table that can be linked back to the original table?

@phumengam , The first one should not give an error, if you are creating a table.

Put these three measures on matrix value, And use show on row and check

 

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.