Forum Discussion

MichaelRensing's avatar
2 years ago

Converting Tableau calculation

I have searched but haven't found exactly what I am looking for. I have a Tableau Calculation that I am trying to convert to Power BI. It is a weighted average, and in Tableau there are a couple of calculations that cascade to get to the final.

 

 

Wieght 1 = SUM([Area SF])/WINDOW_SUM(SUM([Area SF]), FIRST(), last())
Weight 2 = AVG([Net pEUI Reduction Percent])*[Weight 1]
Weighted Average = window_sum([Weight 2])

 

 

How can I / what is the best way to convert this to Power BI?

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    MichaelRensing These generally go better if you provide sample data and expected output. You could try this for a weighted average: Better Weighted Average per Category - Microsoft Fabric Community

     

    Otherwise, Sorry, having trouble following, can you post sample data as text and expected output?
    Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

    Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

    • MichaelRensing's avatar
      MichaelRensing
      Helper I

      Greg_Deckler 

       

      Thanks for the response. I am looking to find a weighted average of Net pEUI (decimal value), weighted by the area (square footage) of a project.  The Visual will show the Net pEUI, and I would like to show the weighted average for all projects on the visual.  The visual could be filtered by Reporting Year and by Primary Use Type. (Sample of data set below)

      Project numberArea SFNet pEUI Reduction PercentReporting yearPrimary Use Type
      12692.175999442022Health Care - Medical Office
      12868.7133500442022Health Care - Medical Office
      13137.04210000582023Education - College/University (campus-level)
      13159.0761000028.272021Health Care - Hospital Inpatient
      13337.0243900422020Retail Store
      13453.0149000442023Public Assembly - Library
      13470.0364809442023Public Assembly - Entertainment/Culture
      13550.0110498422021Health Care - Medical Office
      13697.02170361262021Office - Large
      13697.0348631632023Education - College/University (campus-level)
      13703.015257927.582021Health Care - Hospital Inpatient
      13745.0167931422021Public Assembly - Entertainment/Culture
      13750.01570063.42021Office - Small ( < 10,000 sf)
      13921.015637131.42021Public Assembly - Recreation
      13964.0235249102021Office - Medium (< 100,000 sf)
      13966.01133938422021Health Care - Medical Office
      13992.0111700502022Public Assembly - Library
      14049.0256500422021Health Care - Medical Office
      14081.0115310065.122021Education - College/University (campus-level)
      14087.015457324.032020Lodging - Residence Hall/Dormitory
      14094.021120366.372022Education - College/University (campus-level)

       

      based on the above data, project number 13159.07 has a Net pEUI 28.27, 13750.01 has a Net pEUI of 63.4.  These 2 projects do not have equal effects on the weighted average since the 13159.07 project has an area 610,000 sqft where 13750.01 has an area of 5,700 sqft.  The former's area is much greater than the later so the 2 Net pEUI's are not equal.  The weighted average of the 2 example projects would be somewhere around 28.587 Net pEUI.  so the 1st projects pEUI has the greatest impact due to the weighting.

      I hope this makes sense.