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.
I had a measure for max current quarter as
Max Current Yr Qtr = format(MAXX(FILTER(v_tcp_enrollment,v_tcp_enrollment[ag_level]="QTR"&& v_tcp_enrollment[year_group]="TY"), v_tcp_enrollment[fiscal_nbr_in_year]),"string")
However, even though the max returns the value "2", when I use it in the formula for Enrolled Count QTD (formula below) it adds up the totals for both quarter 1 and quarter 2. I had to switch the measure Max Current Yr Qtr to a calculated column instead of a measure in order for the formula below to work. I don't want a column, because now I have a column reserved to hold the number "2" on every row. Is there an easier way to to this?
Enrolled Count QTD = IF(v_tcp_enrollment[ag_level] = "QTR" && v_tcp_enrollment[year_group] = "TY" && format(v_tcp_enrollment[fiscal_nbr_in_year],"") = v_tcp_enrollment[Max Current Yr Qtr],v_tcp_enrollment[enrolled_count],0)
Solved! Go to Solution.
Hello @lauriemclolo,
Thank you for reaching out to the Microsoft Fabric Forum Community.
I’ve reproduced your scenario in Power BI Desktop using sample data that mirrors your v_tcp_enrollment table, and I was able to achieve the expected output: summing the enrolled_count only for the maximum quarter (2) where ag_level = "QTR" and year_group = "TY", without using a calculated column.
The issue occurs because the original Enrolled Count QTD measure doesn’t correctly apply the max quarter filter in the row context. To resolve this, I’ve created two measures:
Here are the DAX measures:
Max Current Yr Qtr = FORMAT( MAXX( FILTER( v_tcp_enrollment, v_tcp_enrollment[ag_level] = "QTR" && v_tcp_enrollment[year_group] = "TY" ), v_tcp_enrollment[fiscal_nbr_in_year] ), "0" )
Enrolled Count QTD = VAR MaxQtr = MAXX( FILTER( ALLSELECTED(v_tcp_enrollment), v_tcp_enrollment[ag_level] = "QTR" && v_tcp_enrollment[year_group] = "TY" ), v_tcp_enrollment[fiscal_nbr_in_year] ) RETURN CALCULATE( SUM(v_tcp_enrollment[enrolled_count]), v_tcp_enrollment[ag_level] = "QTR", v_tcp_enrollment[year_group] = "TY", v_tcp_enrollment[fiscal_nbr_in_year] = MaxQtr )
I’ve attached a sample .pbix file that demonstrates the solution with the sample data and visuals (a card showing Max Current Yr Qtr = 2 and Enrolled Count QTD = 150, plus a table to verify the results).
Thank you, @Shravan133 for sharing valuable insights.
If this information is helpful, please “Accept as solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
Hello @lauriemclolo,
Thank you for reaching out to the Microsoft Fabric Forum Community.
I’ve reproduced your scenario in Power BI Desktop using sample data that mirrors your v_tcp_enrollment table, and I was able to achieve the expected output: summing the enrolled_count only for the maximum quarter (2) where ag_level = "QTR" and year_group = "TY", without using a calculated column.
The issue occurs because the original Enrolled Count QTD measure doesn’t correctly apply the max quarter filter in the row context. To resolve this, I’ve created two measures:
Here are the DAX measures:
Max Current Yr Qtr = FORMAT( MAXX( FILTER( v_tcp_enrollment, v_tcp_enrollment[ag_level] = "QTR" && v_tcp_enrollment[year_group] = "TY" ), v_tcp_enrollment[fiscal_nbr_in_year] ), "0" )
Enrolled Count QTD = VAR MaxQtr = MAXX( FILTER( ALLSELECTED(v_tcp_enrollment), v_tcp_enrollment[ag_level] = "QTR" && v_tcp_enrollment[year_group] = "TY" ), v_tcp_enrollment[fiscal_nbr_in_year] ) RETURN CALCULATE( SUM(v_tcp_enrollment[enrolled_count]), v_tcp_enrollment[ag_level] = "QTR", v_tcp_enrollment[year_group] = "TY", v_tcp_enrollment[fiscal_nbr_in_year] = MaxQtr )
I’ve attached a sample .pbix file that demonstrates the solution with the sample data and visuals (a card showing Max Current Yr Qtr = 2 and Enrolled Count QTD = 150, plus a table to verify the results).
Thank you, @Shravan133 for sharing valuable insights.
If this information is helpful, please “Accept as solution” and give a "kudos" to assist other community members in resolving similar issues more efficiently.
Thank you.
Thank you for your help. I accepted as solution though I was able to do without the allselected . Is there a reason why I need to add "allselected" in the equation? Here is my version:
Try this:
Enrolled Count QTD =
VAR MaxQtr =
MAXX(
FILTER(
v_tcp_enrollment,
v_tcp_enrollment[ag_level] = "QTR"
&& v_tcp_enrollment[year_group] = "TY"
),
v_tcp_enrollment[fiscal_nbr_in_year]
)
RETURN
IF(
v_tcp_enrollment[ag_level] = "QTR"
&& v_tcp_enrollment[year_group] = "TY"
&& v_tcp_enrollment[fiscal_nbr_in_year] = MaxQtr,
v_tcp_enrollment[enrolled_count],
0
)
This didn't work with the if statement. Not sure why.
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 |
---|---|
78 | |
76 | |
53 | |
37 | |
31 |
User | Count |
---|---|
101 | |
56 | |
51 | |
45 | |
40 |