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

Create a measure to calculate average by row

Hello everyone, 
I am working with the price of many products and I need to create a measure that shows the average price of them. I have the following table 

"PRESENTACION" are the name of the products, and "WALMART", "FARMACIAS DEL AHORRO", "FARMATODO", "FARMACIAS SAN PABLO" are the name of the columns that contains the prices of each product. 

I need to create a measure that calculates the average of price of the products.

I tried with the average function but it calculates it by row. 

 

What I need to do is like the last screen capture of excel but with a measure in power BI. 

Hope you can help me. 

Thank You.

Sin título.png

 

 

Sin título1.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@Anonymous  - 

Ideally, you would Unpivot the multiple separate columns into an Amount column and have another column which indicates the store. 

 

As it stands now, you would need to refer to each column within a measure, like this:

Your Measure = 
var Total = SUM(YourTable[Walmart]) + SUM(YourTable[Store2]) + SUM ......
var ValueCount = IF(ISBLANK(SUM(YourTable[Walmart])),0,1) + IF(ISBLANK(SUM(YourTable[Store2])),0,1) + ......
return DIVIDE(Total,ValueCount)

Hope this helps,

Nathan

View solution in original post

1 REPLY 1
Anonymous
Not applicable

@Anonymous  - 

Ideally, you would Unpivot the multiple separate columns into an Amount column and have another column which indicates the store. 

 

As it stands now, you would need to refer to each column within a measure, like this:

Your Measure = 
var Total = SUM(YourTable[Walmart]) + SUM(YourTable[Store2]) + SUM ......
var ValueCount = IF(ISBLANK(SUM(YourTable[Walmart])),0,1) + IF(ISBLANK(SUM(YourTable[Store2])),0,1) + ......
return DIVIDE(Total,ValueCount)

Hope this helps,

Nathan

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.