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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Credo
Helper I
Helper I

Total by level with bridge table

Hi

 

I am trying to calculate a Total by Customer or Date depending on matrix drillthrough

 

I have sales data with three levels - Month/Customer/Customer shop

 

I've played around with a mockup table trying to understand what different DAX functions do and I've come up with this which seems to do what I need. 

 

Total Sales by level =
CALCULATE (
    SUM ( 'FactSales'[Sales] ),
    ALLEXCEPT ( 'FactSales', 'FactSales'[Month], 'FactSales'[Customer])
)

The problem is once I plugged it into my actual model, it does not behave the way I tested it. 

 

My model consists of 4 tables. 1) FactSales 2)Calendar Dim 3) Customer bridge 4)Customer Dim

 

I tried using the same formula but applied to my model, I even dropped the date dimension to keep it simple for now. 

Total Sales by level =
CALCULATE (
    SUM ( 'FactSales'[Sales] ),
    ALLEXCEPT ( 'Customer Dim', 'Customer Dim'[Customer] )
)

When I try to do a matrix with Customer/Customer Shop/Sales/Sales by level measure

 

I get

 

untitled.png

 

The number is correct however I dont need it calculating for the customer shop rows where there were no sales. I've tested this a number of ways and it seems to be caused by the M - bridge (1) - M relationship that I have between my Fact and Customer Dim tables. 

 

How can I adjust the formula to only calculate for customer shop where there have been sales?

 

4 REPLIES 4
v-yulgu-msft
Employee
Employee

Hi @Credo,

 

Do adding field from Customer Dim tables rather than from fact table into Matrix solve this problem?

 

Regards,

Yuliana Gu

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

Unfortunetly no combination of fields either from the fact table or from Dim table helps fix the problem.

 

I was going to upload my file to provide more context, however than I noticed that there is something wrong with my Dim table.

 

The dim table has Customer Shop ID / Sales Channel / Customer / Customer Shop Adress. At first I noticed that the reason I have duplicate values in  Customer Shop ID is because same ID can be repeated for each Sales Channel. That does make sense. However than I noticed that a single customer shop address can multiple customer shop IDs associated with it. That makes zero sense. The ID should be 1:1 to the full physical address. 

 

I think that when I made my Dim table from the OLAP report, I pulled a wrong ID field. I am gonna try fix the Dim table and see whether that resolves the issue. 

Hi @Credo,

 

Have you resolved the problem?

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Sample data would be very helpful. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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