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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
LucaUSA50
Frequent Visitor

Aggregation of calculated field

Hello everybody,

 

I am using power pviot to analyze data about daily stock (daily inventory level).

The input are the month opening inventory and the daily inventory movements.

Inventory at day x is given by a calculated field:

 

calculate(sum(Main_Analys_Matrix[M15]),DATESMTD(DATEADD(Main_Analys_Matrix[Date],-1,day)))

+0

+calculate(sum(Main_Analys_Matrix[Opening_SAP_D_1]),DATESMTD(DATEADD(Main_Analys_Matrix[Date],0,day)))

 

The first calculate sum the opening inventory up to the day x (opening inventory has a value at day 1 of the month and zero the others day)

The second calculate sum the inventory movements up to the day x

+0 is just a trick to have zero instead no value in the pivot tables

 

Formula works, and caluculate the daily inventory.

 

 

Now I would like to calculate the month average of this caluculated field (in order to add a orizontal line in the charts). I tried various formulas but I could not meet my objetive (SUMX, AVERAGEX, CALCULATE seems don't work if they act on a calculated field).

 

Do you have any suggetions?.

 

Thanks

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@LucaUSA50,

 

Try to add ALLSELECTED Function in your formula.

https://community.powerbi.com/t5/Desktop/Incorrect-matrix-row-total/m-p/287567#M126498

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@LucaUSA50,

 

Try to add ALLSELECTED Function in your formula.

https://community.powerbi.com/t5/Desktop/Incorrect-matrix-row-total/m-p/287567#M126498

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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
Top Kudoed Authors