Share via

Calculated field returning wrong answers

Anonymous
2023-08-31T19:50:38+00:00

I have a pivot table with data grouped by weeks. There are two fields that I need to know what percentage one field is of the other. My calculated field is returning the wrong answer. For the calculated field I am using this formula: ='Premium Widgets'/'All Widgets'

Row Labels Widgets Sold Premium Sold % Premium Expected Result
1/1/2023 - 1/7/2023 344 152 68% 44%
Baton Rouge 17 9 75% 53%
Connecticut 1 0 0% 0%
Fayetteville 3 1 66% 33%
Gainesville 1 1 100% 100%
Hampton Roads 13 6 74% 46%
Kansas 113 50 67% 44%
Lafayette 13 8 84% 62%
Las Vegas 7 6 96% 86%
Macon 4 1 56% 25%
New Orleans 40 5 31% 13%
Northern Virginia 3 2 89% 67%
Oklahoma City 11 8 91%
Omaha 15 8 74%
Orange County 28 15 72%
Pensacola/Ft. Walton Beach 10 3 44%
Phoenix 28 11 66%
Rhode Island 7 5 87%
Roanoke 1 1 100%
San Diego 22 7 51%
Santa Barbara 1 1 100%
Tucson 4 2 57%
Tulsa 2 2 100%
1/8/2023 - 1/14/2023 468 207 69%
Baton Rouge 24 11 70%
Connecticut 8 4 80%
Fayetteville 3 2 88%

Here is a link to a simplified version Demo Data.xlsx

Thanks in advance for any help you can offer!

Microsoft 365 and Office | Excel | For business | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

HansV 462.6K Reputation points
2023-08-31T20:20:36+00:00

The calculated field computes (sum of premium widgets)/(sum of all widgets).

For example for Fayetteville, January 1 to 7:

Sum of premium widgets = 402

Sum of all widgets = 609

402/609 = 66%

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2023-09-01T12:08:16+00:00

    The calculated field computes (sum of premium widgets)/(sum of all widgets).

    For example for Fayetteville, January 1 to 7:

    Image

    Sum of premium widgets = 402

    Sum of all widgets = 609

    402/609 = 66%

    OK, that helped. The numbers in the columns are only codes from the source data. So I created helper columns to replace those codes with "1" as appropriate and now the math works and the percentages are right.

    Thanks!

    Was this answer helpful?

    0 comments No comments
  2. Ashish Mathur 101.9K Reputation points Volunteer Moderator
    2023-08-31T23:07:09+00:00

    Hi,

    Load the data to the Data Model and write this measure

    Measure1 = divide(sum(Data[Premium sold]),sum(Data[Widgets sold]))

    Hope this helps.

    Was this answer helpful?

    0 comments No comments