Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello Power Bi Community,
I am new to Power Bi and trying to understand how to do a fairly complex DAX calculation. I have several weighted averages I would like to calculate but the denomanator is changing based on several criteria. Heres a short snippet of my example.
Project Name | Sector | Reporting Year | % Savings | Area |
Project 1 | HE | 2019 | 50 | 100000 |
Project 2 | GO | 2019 | 32 | 50000 |
Project 3 | GO | 2019 | 43 | 75000 |
Project 4 | HE | 2019 | 28 | 35000 |
Project 1 | HE | 2020 | 53 | 100000 |
Project 2 | GO | 2020 | 36 | 50000 |
Project 3 | GO | 2020 | 45 | 75000 |
Project 4 | HE | 2020 | 28 | 35000 |
The numbers I am trying to calucalte include:
Area Weighted % Savings by Reporting Year = % Saving * Area / SUM(Area by Reporting Year)
Area Weighted % Savings by Reporting Year and Sector = % Savings * Area / SUM(Area by Reporting Year and Sector)
My method so far as been to create individual columns for each of these steps.
Area by Year = CALCULATE(SUM('Table'[Area]), ALLEXCEPT('Table','Table'[Reporting Year]))
I then setup Area by Reporting Year and Sector, one per column:
HE Area by Year = CALCULATE(
SUM('Table'[Area]),
ALLEXCEPT('Table','Table'[Reporting Year]),
'Table'[Sector]="HE")
I then use each of these in the denomenator of the Area Weighted % Savings equation. With the number calculated I'm creating visualizations in the Report tab and trying to filter by Reporting Year and Sector.
I believe there is some way I can get the SUM Total Area by Report Year, Sector, and other criteria without creating so many columns. Is there an easier way to do this with a DAX equation?
You don't really want to use columns for that. Transform them to measures.
When you create your DAX formula, use copious amounts of variables to validate that your intermediate steps do what you want. Since in DAX everything is a table (just sometimes a single row/single column table), use CONCATENATEX to visualize your intermediate results.
An example for the first measure would be
Hello @lbendlin, thank you for your reply. I was not aware that you can use var to hold variable information. I have two follow up questions to expand my understanding for more applications.
Thank you for taking the time to help me with my beginner questions.
1. yes, CALCULATE() and many other functions accept multiple filters that are ANDed together. You can als use &&, || and IN for more elaborate filters (at a storage engine performance cost). Check the documentation for detailed syntax.
2. "it depends" - do you want the year as an attribute in the scatter, or do you want to ignore it?
2. I would like the year as an attribute. I would like to display the results for the measure based on the results of year [Reporting Year]. So the % of Year measure is on the Y-axis and Reporting Year is on the X-axis.
That would give you a scatter plot with vertical columns of dots for each year. Are you sure you want that?
I believe I mis-understand then. Below are two images of what I'm working with.
The first is close to what I want but the orange dot is the measure we created, notice it's only on 2021.
The second graphic is the measure on a scatter plot by itself.
This is what I want but the orange dot spread across the years.
This is what I got instead.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
19 | |
14 | |
14 | |
11 | |
9 |