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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
rpinxt
Power Participant
Power Participant

Only count/sum Quantity of last log date

So I have this table output:

rpinxt_0-1690368866685.png

So I have a delivery with multiple materials.

But some of these materials (see for example the yellow) have 2 log dates.

The correct Quantity for  this material would be 2 and not 4 (when I would take out the date)

 

Made QCorr like :

QCorr = CALCULATE([Quantity],Test[LogDate] = Test[MaxLog])
Actually expected this would work. No clue why it still shows 2 where logdate is 18 and maxlog is 19.
 
But this is not doing what I want.
In the end I want to take the dates out and that material should show 2.
Because the total should be 102 not 122.
122 is because all of the doubles in this delivery.
 
How can I make it 

 

1 ACCEPTED SOLUTION
mlsx4
Memorable Member
Memorable Member

Opsss... I copied badly the measure:

 

 

QCorr = SUMX(VALUES('Table'[Material]),[sumSc])

mlsx4_0-1690372996662.png

 

 

View solution in original post

6 REPLIES 6
rpinxt
Power Participant
Power Participant

@mlsx4 
unfortunately not:

rpinxt_0-1690369510171.png

 

ps: maxlog is a calculated column

mlsx4
Memorable Member
Memorable Member

Hi @rpinxt 

 

I have created an auxiliary sum to get the maximum value in case of several rows:

 

 

sumSc = CALCULATE(MAX('Table'[Quantity]), FILTER(ALLEXCEPT('Table','Table'[Material]), 'Table'[LogDate]=MAX('Table'[LogDate])))

 

 

 And now, in QCorr:

 

 

 

QCorr = SUMX(VALUES('Table'[Material]),IF(DISTINCTCOUNT('Table'[Material])>1,[sumSc],SUM('Table'[Quantity])))

 

 

You don't need any "MaxLog" column

 

mlsx4_0-1690371613350.png

 

rpinxt
Power Participant
Power Participant

Thanks @mlsx4 but look on the second row....it says 4 and should be 2.

 

Yes your total of 102 is correct but if you sum all the line separate you will again get 122.

mlsx4
Memorable Member
Memorable Member

Opsss... I copied badly the measure:

 

 

QCorr = SUMX(VALUES('Table'[Material]),[sumSc])

mlsx4_0-1690372996662.png

 

 

rpinxt
Power Participant
Power Participant

Yes thanks @mlsx4 this seems to work.
But you need to remove the date colunns.

 

This is part of a bigger thing.

I have more countries, deliveries and months etc.

 

I should all go into a stacked column chart.

With periods on the x-axis where I link a date field (maxlog) to a date table (auto).

Wondering if it will give the correct output.

But will test. Thanks for this!

mlsx4
Memorable Member
Memorable Member

I think you shouldn't include those columns in the table or they will be added to the sum. If you just leave delivery, material and qcorr, it should work.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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