Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi,
I have a monthly trend table where I need to calculate the sum of patients with few filters and conditions applied. See the below measure -
Below is the table that I am using -
Hi @Pdawar,
It sounds like a common multiple level aggregation calculate requirement in Dax. You can refer to the Greg’s blog to know how to handle this scenario: (SUMMARIZE function and iterator aggregation functions)
Measure Totals, The Final Word
Regards,
Xiaoxin Sheng
I am not sure how to apply this because it involves applying the if condition as well. Also, the filter that we need to apply are from different tables as the data model is star schema. If we go ahead with this measure, how can we apply filter conditions from different tables and if conditions?
Certainly! It looks like you want to calculate the sum of patients with specific filters and conditions, and you want these conditions to be applied before aggregation to get accurate totals. To achieve this, you can use the FILTER function along with SUMX instead of CALCULATE. Here's a modified version of your measure:
Patients_Adj =
SUMX (
FILTER (
Patients,
Patients[TYPE] = "Paid" &&
Patients[PRODUCT_FK] = "Product A" &&
'Date'[Month] >= [max_Date]
),
Patients[Patients]
)
This measure uses the FILTER function to create a table where the specified conditions are met, and then uses SUMX to iterate over that table and calculate the sum of patients. This way, the conditions are applied before the aggregation.
Make sure to replace [max_Date] with the appropriate reference to the maximum date you're comparing against. This measure should provide accurate totals because it applies the conditions at the row level before summing up the values.
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 |
---|---|
14 | |
11 | |
10 | |
10 | |
9 |
User | Count |
---|---|
18 | |
13 | |
12 | |
11 | |
8 |