+ Reply to Thread
Results 1 to 7 of 7

Collaps group in pivot lead to wrong values with Measures created

  1. #1
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    156

    Collaps group in pivot lead to wrong values with Measures created

    Hi,

    i am working with powerquery to clean up some oven records. finally i get a list which looks like the attached file.
    I load the result into the datamodel and want to calculate the usage per day per oven (=OEU) by adding some measures.
    In total I created 4 Measures leading to the OEU which I need.

    Calculation should be:
    Per oven:
    e.g. one oven is running 12 hours, usage per day is 12/24 = 0.5

    daily usage is "Total running hours for all ovens" / (8*24) as i have 8 ovens in total and i always want to compare to all ovens per day

    I run into two issues now.

    1st problem: The daily numbers are correct, but when I group the pivot table to e.g. week the summary of the week is wrong. It shows the summary of the whole selection instead!
    2nd Problem: Daily usage only show the usage for the oven actually running, not for all 8 ovens.

    Where is my failure? I guess I need to use the Measures as I want to sum each single row and based on this do the calculation of the OEU

    thanks for your help
    Attached Files Attached Files
    Last edited by hansolu; 01-05-2021 at 04:47 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Powerquery and DAX

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however the thread title does not really convey what your request is about. Tell us what you are trying to do, not how you think it should be done.

    Please take a moment to amend your thread title. Make sure that the title properly explains your request. Your title should be explicit and not be generic (this includes function names used without an indication of what you are trying to achieve).

    Please see Forum Rule #1 about proper thread titles and adjust accordingly. To edit the thread title, open the original post to edit and then click on Go Advanced (bottom right) to access the area where you can edit your title.

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    156

    Re: Powerquery and DAX

    Hi

    sorry, i just changed the title. Sorry, will be doing better next time

    br
    Hansolu

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,559

    Re: Collaps group in pivot lead to wrong values with Measures created

    Thank You for changing the title.
    If I understand then perhaps the following will help.
    1. Produce an unpivoted table as modeled in Table1_2 on the PQ Table sheet using the following M Code in the Power Query advanced editor:
    Please Login or Register  to view this content.
    2. A pivot table was produced using the new table
    3. Date (grouped into 7 days intervals) is in the Rows area
    4. Oven is in the Columns area
    5. Time (hrs) is used twice in the Values area, with the second usage being percentage of row total
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    156

    Re: Collaps group in pivot lead to wrong values with Measures created

    Hi
    thanks for the reply. This is one option but not the one I am looking for.
    Let me try to explain a bit deeper.

    If i use the calculation percentage of row total I do get a wrong value. The value should be e.g.
    8 oven times 24 hours per day times 7 days a week = 1344 total hours available. % usage should be how much of these hours the oven where running. So if i only use 1000 hours the percentage in total is 1000/1344 = 74%

    Now I need to dive in and see why the usage is only 74%. This could be because i did not use one oven at all or all ovens did a bad performance.
    So I want to drill down and see the % usage per oven in this period. Then I want to drill down and see the % usage per day per oven.

    I used two different PQ to show one time the weekly performance and then a second PQ to show the performance by day and oven. But i want to combine and only use one final Pivot table where I can choose the filter or collaps/expand to show my period/oven of interest.

    So in my opinion I need to summarize the duration per oven and day based on the selection and then divide to the total time available for the days and selected ovens. One oven has 24 hours availability per day.
    Thats why i used the DAX formula but as soon as i collaps the week Excel show the total numbers for the whole column for all periods available and not only the values for the collapsed period.

    I hope its more clear what i want.

    thanks

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,559

    Re: Collaps group in pivot lead to wrong values with Measures created

    I believe that I have an answer for question #1 (post #1)
    Modify the Duration per day and oven measure to read: =SUM([Duration])
    As it is context driven it will show either the sum per day when the week is expanded or sum per week when the week is collapsed (i.e. oven 3 is used 79.24 hours in week 50).
    As for question #2 I feel as if you will have to fill in every day of the week and give a value to every oven in order to get the OEU to calculate correctly (see rows 107 and 142 on the raw data sheet).
    Let us know if you have any questions.

  7. #7
    Forum Contributor
    Join Date
    10-14-2020
    Location
    Shanghai
    MS-Off Ver
    O365
    Posts
    156

    Re: Collaps group in pivot lead to wrong values with Measures created

    Hi,

    thanks for the ideas. I now did some other steps.
    Create a calendar table
    create a oven table and append it to the Calendar table
    Then use the actuals and merge it with the previous table
    Then in the datamodel use the DAX formula to show the OEU.
    Seems to work, but a bit of a work to do in the first place.

    Maybe i am still able to improve a bit

    thanks

+ 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. PowerQuery index match prioritized criteria from 2 columns
    By Imbizile in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2020, 08:52 AM
  2. PowerQuery
    By wherdzik in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-08-2020, 03:03 PM
  3. PowerQuery in Excel: Use an Excel table to populate SQL table in PowerQuery
    By joeyslaptop in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-25-2019, 02:33 PM
  4. PowerQuery Many 2 Many Relationships
    By rabbit_post in forum Excel General
    Replies: 1
    Last Post: 02-01-2018, 05:17 PM
  5. VBA vs PowerQuery
    By Trachr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-08-2017, 11:50 PM
  6. PowerQuery and VBA
    By Trachr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-08-2017, 12:10 AM
  7. Help with powerquery.
    By stephme55 in forum Excel General
    Replies: 0
    Last Post: 09-01-2016, 07:31 PM

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