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
bvramilo
Frequent Visitor

Avoid sum multiple times same value on column

Hi everyone, 

 

I have being problems calculating a total on a Matrix: 

 

I have this structure: 

 

Batch

IdBatch

Amount

Connection 1-N with Component table

 

Component
IdComponent

IdBatch

Connected 1-N with Failure table

 

Failure
IdComponent
AmoutFailures
Date

 

So, with this information I create a view like this: 

IdBatchDate AmountAmountFailures
101/04/2024 1002
102/04/2024 1005
201/04/2024 3002
310/04/2024 5000
110/04/2024 10010

 

But when I want to see the relation between number of failures and batch amout, I can calculate de total of failures in the right way, but I am sum more batch amout that I should do

 

The right result should be like this:

BatchYearAmountAmoutFailures
1202410017
220243002
320245000

 

But I am getting this result:

BatchYearAmountAmoutFailures
1202430017
220243002
320245000

As you can see, I am summing the batch amout 3 times.

Maybe, the way I am creating the view is wrong but I don't know how I should create it to import and work easily in Power BI.

 

Thank you in advance

4 REPLIES 4
Sahir_Maharaj
Super User
Super User

Hello @bvramilo,

 

Can you please try the following:

Total Batch Amount = 
SUMX(
    VALUES(Batch[IdBatch]), 
    CALCULATE(
        MAX(Batch[Amount])
    )
)

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution? (Yes, its FREE!)
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning
bvramilo
Frequent Visitor

Thank you so much for the quickly answers, they made me think and prepare and simple example that helps to find the solution: 

 

When I am talking about a view, I mean a database view (data from multiple tables together) and that's here where I made a mistake

My model was like that: 

Esquema.png

That's the data

bvramilo_0-1712737664435.png

So, when I go level down in the grid the behaviour was like this: 

bvramilo_1-1712737774484.pngbvramilo_2-1712737797904.png

As you can see, power bi is multipling the batch amount by the number of registers so the total amout is wrong. 

 

But, as I said before, to show you a simple model I create this one: 

Esquema2.png

It works well cause Power BI knows the amout of batch is not a part of the registers. 

bvramilo_3-1712738947531.pngbvramilo_4-1712738968808.png

 

Now I have to find how to make it work without both direction relation between Revision and Batch. I read that is not recommended 

 

Sorry for make you waste your time and thank you so much. 

Regards, 

Rupak_bi
Responsive Resident
Responsive Resident

Hi,

You need to put the amount column in the row and failures in the value of a matrix visual. you may use date as slicer or in the row above amount in the matrix visual as well.

sjoerdvn
Super User
Super User

I guess with "view" you mean a table or matrix visual, right? assuming that you could just use the amount column from the Batch table and make sure it is not using it as an implicit measure, so:

sjoerdvn_0-1712666424832.png

 



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.