Closed Thread
Results 1 to 2 of 2

How do I create a Weighted Average in DAX

  1. #1
    Registered User
    Join Date
    06-22-2020
    Location
    NY, NY
    MS-Off Ver
    Windows 10
    Posts
    14

    How do I create a Weighted Average in DAX

    Greetings, and lets see if I can do this correctly with the graphics.


    The DAX code which is a typical (as they say) weighted average template follows this text.

    The table that contains the columns; [PRV] & [PRI QTY] to be multiplied and produce the product [Asset Value], follow the DAX code.

    At each row, I want to divide the [Asset Value] by the Sum of the [PRI QTY], not the individual values at the roes themselves.

    As you can see from the column [WAvg], I am getting the same result as [PRV]; why, because I am not retaining the "TotalGSF" from the VAR in the DAX code.

    I thought by using the VAR, the "TotalGSF" would be retained as a constant for the DIVIDE function, but not true, its obvious the row value of [PRI QTY] is being used.

    How do I retain the "TotalGSG" for use in the DIVIDE function? Thank you.
    ____________________________________________________________________________

    WAvg:=VAR TotalGSF = [Total Pri Qty]
    RETURN

    DIVIDE (
    SUMX (
    VALUES ( GFEBS_IDS_ALLSITES[BUSINESS_ENTITY] ),
    CALCULATE(SUM(GFEBS_IDS_ALLSITES[PRV]) * SUM(GFEBS_IDS_ALLSITES[PRI QTY]),
    FILTER(GFEBS_IDS_ALLSITES,
    AND(
    GFEBS_IDS_ALLSITES[BUSINESS_ENTITY] = "24015",
    GFEBS_IDS_ALLSITES[PRIUM] = "SF"
    )
    )
    )
    ),
    TotalGSF
    )

    Total Pri Qty:=CALCULATE(
    SUM(GFEBS_IDS_ALLSITES[PRI_QTY]),
    FILTER(GFEBS_IDS_ALLSITES,
    AND(
    GFEBS_IDS_ALLSITES[PRIUM] = "SF",
    GFEBS_IDS_ALLSITES[BUSINESS_ENTITY] = "24015")
    )


    //the measure that populates the VAR TotalGSF
    Total Pri Qty:=CALCULATE(
    SUM(GFEBS_IDS_ALLSITES[PRI_QTY]),
    FILTER(GFEBS_IDS_ALLSITES,
    AND(
    GFEBS_IDS_ALLSITES[PRIUM] = "SF",
    GFEBS_IDS_ALLSITES[BUSINESS_ENTITY] = "24015")
    )
    )
    __________________________________________________________

    PRV PRI QTY Asset Value WAvg
    1,626,962 5,825 9,477,053,650 1,626,962
    962,771 3,447 3,318,671,637 962,771
    962,771 3,447 3,318,671,637 962,771
    962,771 3,447 3,318,671,637 962,771
    962,771 3,447 3,318,671,637 962,771
    7,691 64 492,224 7,691
    1,106,614 3,962 4,384,404,668 1,106,614

  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,872

    Re: How do I create a Weighted Average in DAX

    Administrative Note:

    Welcome to the forum.

    Unfortunately, this is a duplicate thread, and you are allowed only ONE thread per issue here.

    Please see Forum Rule #5 about thread duplication.

    I am closing this thread, but you may continue here in the original thread:
    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

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 07-19-2019, 04:47 PM
  2. Weighted Average Function for Series Weighted by Increments of 1
    By kratsexcel in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 10-05-2018, 11:38 AM
  3. Replies: 0
    Last Post: 02-15-2018, 03:04 AM
  4. Query regarding Calculating Weighted average value or average value in Percentage.
    By adamsmith1337 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-03-2016, 07:56 AM
  5. [SOLVED] Average Percentage (weighted average) but I want to exclude N/A
    By mespinoza in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 12-28-2015, 02:53 PM
  6. Converting Weighted Average to Average If
    By renstoecklin1991 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-18-2015, 02:51 PM
  7. [SOLVED] What is this kind of average called?-weighted average
    By havocdragon in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 06-24-2005, 01:05 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