Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
BA_AD_AZ
New Member

Conditional Sum for Amount

Hello,

I am new to Report Builder and I am seeking assistance to write an expression that is a conditional sum.

I am attempting to sum the “Check/EFT Amount” values, if the “Check/EFT Number” is between the first and last “Check/EFT Number” values of the semantic model dataset. The first and last “Check/EFT number” values are dynamic value and will change based on the provided parameter date value. The Starting query below is the query from SAP business objects that I am attempting to replicate in Report Builder.

 

The Error I receive is “uses a First, Last or Previous aggregate in an outer aggregate.  These aggregate functions cannot be specified as nested aggregates.”

 

For reference, I have attempted to use Min and Max, which avoids the error but the resulting values are different than First and Last. Therefore I do not receive the expected sum amount. I have also attempted a custom code solution with no success.

 

Starting Query (SAP):

 =Sum([DISB Actg Line Check Amt])

Where ([DISB Hdr Check No] >= [Var - Begin Check Number ] And [DISB Hdr Check No] <= [Var - End Check Number])

 

My Report Builder Expression:

=Sum(IIf(Fields!Check_EFT_Number.Value >= First(Fields!Check_EFT_Number.Value) And Fields!Check_EFT_Number.Value <= Last(Fields!Check_EFT_Number.Value), Fields!Check_EFT_Amt.Value, 0))

 

BA_AD_AZ_0-1716224857736.png

 

1 REPLY 1
ryan_mayu
Super User
Super User

cuold you pls provide some sample data and exepcted output?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors