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

Wrong Totals after unpivoting some columns

HI Team,

 

i unpivoted 5 columns into one column namely agetype and value. 

I am getting wrong totals for products as shown in the image. it is calculating 5 times the total ap balance for a given vendor, thereby giving wrong totals. 

 

please advice on how to resolve this. Capture.JPG

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

hi, @Anonymous 

For your case, you could try this way:

this is my basic sample data

1.JPG

Now I unpivot the columns(Type1...Type5)

2.JPG

Now use AVERAGE and SUMX Function to create a measure like this:

Measure = var _table=SUMMARIZE('Table','Table'[Vendor]) return
SUMX(_table,AVERAGE('Table'[Qty]))

Result:

3.JPG

Here is my sample pbix file, please try it.

If it is not your case, please share sample pbix file and expected output . You can upload it to OneDrive and post the link here. Do mask sensitive data before uploading.

 

By the way: there is a measure totals knowledge for this case. See the post about it here:

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

Best Regards,

Lin

 

Community Support Team _ Lin
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

4 REPLIES 4
banjofork
Regular Visitor

Same issue, but in my case the instead of numbers i have a string and the calculation doesn't work any tips ?

 

v-lili6-msft
Community Support
Community Support

hi, @Anonymous 

For your case, you could try this way:

this is my basic sample data

1.JPG

Now I unpivot the columns(Type1...Type5)

2.JPG

Now use AVERAGE and SUMX Function to create a measure like this:

Measure = var _table=SUMMARIZE('Table','Table'[Vendor]) return
SUMX(_table,AVERAGE('Table'[Qty]))

Result:

3.JPG

Here is my sample pbix file, please try it.

If it is not your case, please share sample pbix file and expected output . You can upload it to OneDrive and post the link here. Do mask sensitive data before uploading.

 

By the way: there is a measure totals knowledge for this case. See the post about it here:

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907

 

Best Regards,

Lin

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thanks Lin @v-lili6-msft 

 

This worked for me !! thanks for your example; which made it easier to understand. 

 

Regards,

Ronak

Anonymous
Not applicable

Thanks Lin @v-lili6-msft 

 

This worked for me !! thanks for your example; which made it easier to understand. 

 

Regards,

Ronak

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.