+ Reply to Thread
Results 1 to 12 of 12

PowerPivot showing average instead of sum

  1. #1
    Registered User
    Join Date
    10-10-2022
    Location
    Cph, Denmark
    MS-Off Ver
    365 Enterprise
    Posts
    6

    PowerPivot showing average instead of sum

    Dear all

    I'm quite new to the world of Dax and Powerpivot.

    In this dataset I have the actual number of visits for sales reps in a certain district by store. This I did with a simple countrows function and it works...

    I also have a theoretical # of visits. This is a measure where I calculate how many visits the sales rep is actually expected to have conducted in a certain time period.
    This is calculated as a measure by multiplying the number of days selected in the pivot with the number of visits pr day expected (e.g. 30 days * 0,0328 visits/day = 0,98 visits (rounded up to 1) in a period of 30 days)

    The issue occurs in the pivottable, where the subtotals for visits are summed but the subtotals for theoretical visits are avaraged... (see pictures)

    Are there any quick fixes to make the pivot sum, instead of averaging, on the theoretical visits? (See attached picture)...

    (Probably difficult to answer without some data...but I'll have to anonymize it before uploading, if necessary)

    Thanks in advance

    mr_jules2
    Attached Images Attached Images

  2. #2
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: PowerPivot showing average instead of sum

    Subtotals do exactly the same calculation as at the other levels. It appears you want a different calculation at that level, so you'll need to factor that into your measure. There are numerous examples here and elsewhere of this sort of calculation but if you need specific help, you will need to post a sample workbook.
    Rory

  3. #3
    Registered User
    Join Date
    10-10-2022
    Location
    Cph, Denmark
    MS-Off Ver
    365 Enterprise
    Posts
    6

    Re: PowerPivot showing average instead of sum

    Fair enough

    I have attached a scraped down version of my file, where you might be able to see my calculations.

    Again, the green data in the attached picture is behaving as wanted - the red not (obviously because im calculating something wrongly)

    Thanks for any assistance!

    BR

    mr_jules2
    Attached Images Attached Images
    Attached Files Attached Files

  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: PowerPivot showing average instead of sum

    I assume that for each of the red cells you want the sum of the green?

  5. #5
    Registered User
    Join Date
    10-10-2022
    Location
    Cph, Denmark
    MS-Off Ver
    365 Enterprise
    Posts
    6

    Re: PowerPivot showing average instead of sum

    Exactly

  6. #6
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: PowerPivot showing average instead of sum

    This is proving trickier than anticipated due to the way you calculate the start and end date. I'm still working on it though.

  7. #7
    Registered User
    Join Date
    10-10-2022
    Location
    Cph, Denmark
    MS-Off Ver
    365 Enterprise
    Posts
    6

    Re: PowerPivot showing average instead of sum

    Much appreciated.

    If it would help to manually input a start and end date in the excel directly...that's fine by me also... don't know if that could eliminate the tricky part...?

    mr_jules2

  8. #8
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: PowerPivot showing average instead of sum

    I don't think so. The problem is that you have different periods involved for different entities. For example, the Days2 calculation for Ica Kvantum Tomelilla equals 30, whereas for all the other Ica Kvantum entities, it's 61. So at the aggregate level you need a table summary that includes the relevant days2 calculation for each customer name, which is harder than I expected. I thought that a simple formula like:

    =if(ISFILTERED([Customername]),[Days2]*AVERAGE(eLeaderVisit[Bes?k pr dag (teori)]),SUMX(VALUES(eLeaderVisit[Customername]),[Days2]*AVERAGE(eLeaderVisit[Bes?k pr dag (teori)])))

    would work, and it does up to the Besokskod level, but above that the Days2 calculation is the same number of days for every customer.

  9. #9
    Registered User
    Join Date
    10-10-2022
    Location
    Cph, Denmark
    MS-Off Ver
    365 Enterprise
    Posts
    6

    Re: PowerPivot showing average instead of sum

    Hi rorya

    That is probably an error on my part. What I am trying to do in Days2 is simply to calculate how many days there are in the timeperiod chosen in the pivot (there is probably a smarter ways to do this) .
    I suspect I have overlooked the all(bes?kskod) to the Min/max date....

    I have added this to the following: StartMonth:=calculate(STARTOFMONTH(eLeaderVisit[Visitdate]);all(eLeaderVisit[COMSYS customernbr]);all(eLeaderVisit[Customername]);all(eLeaderVisit[Bes?kskod]))
    Now also the kvantum store = 61, which should be the same for alle stores... Does that help?

    Thanks again for your assistance!

    mr_jules2

  10. #10
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: PowerPivot showing average instead of sum

    In that case try the attached. It uses a new measure with formula:

    =if(ISFILTERED([Customername]),[Bes?g (teori2)],SUMX(VALUES(eLeaderVisit[Customername]),[Bes?g (teori2)]))

  11. #11
    Registered User
    Join Date
    10-10-2022
    Location
    Cph, Denmark
    MS-Off Ver
    365 Enterprise
    Posts
    6

    Re: PowerPivot showing average instead of sum

    It works perfectly, as far as I can see!

    Thanks a lot!

  12. #12
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: PowerPivot showing average instead of sum

    Glad we could help. Thanks for the rep.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 09-26-2020, 09:31 AM
  2. Help With DAX function for calculating Average PowerPivot
    By bconner in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 05-06-2020, 12:06 PM
  3. PowerPivot Weight Average w/ Filters
    By girlnamedP in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-23-2019, 03:25 PM
  4. [SOLVED] powerpivot calculation related showing error message
    By paxonltd in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 02-12-2019, 05:19 AM
  5. PowerPivot/PivotTable showing same results after relationship building.
    By saudi_red_neck in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 07-08-2018, 01:52 AM
  6. PowerPivot (2016) - hourly average and cumulative average ?
    By Cam in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 02-15-2016, 06:32 AM
  7. PowerPivot - Average of the values in a row
    By shadedrivein in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-14-2014, 06:16 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1