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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
AR_Coordo
Frequent Visitor

Aggregation not working with dim table

Hi all,

I am struggling to calculate an aggregated KPI displayed in a matrix.

Let's say I have a dim country table related to a fact sales table :

AR_Coordo_0-1708034761741.png

Country table:

AR_Coordo_3-1708035053142.png

Sales table :

AR_Coordo_4-1708035070460.png

 


My sales are calculated by month and country/city.
I want to display on a matrix the sales total  regardless of the month by country/city and month.

I used this measure :

Total_Sales_Per_Country = calculate(sum('Sales'[Sales]), ALLEXCEPT(Sales, Sales[FK]))

 

However, the result is :

AR_Coordo_1-1708034971254.png


But I want to obtain this :

AR_Coordo_2-1708034997615.png

 

Any idea why it is not working ?

 

Thank you in advance for your help !

 

Regards,

 

Alice

1 ACCEPTED SOLUTION
Daniel29195
Super User
Super User

@AR_Coordo 

 

use this modified version of the code : 

Total_Sales_Per_Country = calculate(sum('Sales'[Sales]), removefilters(sales[Month]) )

or

Total_Sales_Per_Country = calculate(sum('Sales'[Sales]), all(Sales) , values(sales[FK]))


 

 

let me know if this helps .

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

View solution in original post

2 REPLIES 2
Daniel29195
Super User
Super User

@AR_Coordo 

 

use this modified version of the code : 

Total_Sales_Per_Country = calculate(sum('Sales'[Sales]), removefilters(sales[Month]) )

or

Total_Sales_Per_Country = calculate(sum('Sales'[Sales]), all(Sales) , values(sales[FK]))


 

 

let me know if this helps .

 

 

 

If my answer helped sort things out for you, i would appreciate a thumbs up 👍 and mark it as the solution
It makes a difference and might help someone else too. Thanks for spreading the good vibes! 🤠

Thank you for your answer, it worked !

Any idea why it doesn't work if I filter my sales by antoher column from the same table, like 

Total_Sales_Per_Country = calculate(sum('Sales'[Sales]),'Sales'[Category]="XXX", removefilters(sales[Month]) )

?

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.