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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
FRG
Resolver I
Resolver I

Sum most recent entries

Hi,

In one table I have many entries for the same NO_PAL. I added an Index column where the smaller number is the most recent entry. I want to sum "Total" of the last entry of each NO_PAL.

Thanks

Capture.JPG

1 ACCEPTED SOLUTION

Hi @FRG ,

For your requirement, you could create the below measures to achieve your desired output.

minindex = CALCULATE(MIN('Table'[Index]),ALLEXCEPT('Table','Table'[No_PAL]))
Measure =
SUMX (
    FILTER (
        'Table',
        'Table'[Index] = [minindex]
            && 'Table'[No_PAL] = MAX ( 'Table'[No_PAL] )
    ),
    SUM ( 'Table'[Total] )
)

Here is the output.

Capture.PNG

Best Regards,

Cherry

 

Community Support Team _ Cherry Gao
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

5 REPLIES 5
EVEAdmin
Helper V
Helper V

Can you use a filter with the TOP N option? In your case, N will be 1. 

Alternately, you can probably drop the date field in a filter and again use only the TOP 1 record.

Thanks for your reply!

I made this measure to calculate the sum of Total off all the min value for all NO_PAL but it's not what I'm looking for:

SUMX(Table1;CALCULATE(MIN(Table1[Total]);ALLEXCEPT(Table1;Table1[NO_PAL])))

I need the last value of all NO_PAL, wich is determined by the index column. I don't know how TopN function works correctly in this type of measure.

Thanks


@FRG wrote:

Thanks for your reply!

 

I need the last value of all NO_PAL, wich is determined by the index column. I don't know how TopN function works correctly in this type of measure.

Thanks


From that table in your screen shot, what is the "last value of all NO_PAL, which is determined by the index column" ?
Is it 1 ?

I highlighted all the value I want to sum. It's where is the smaller index for each NO_PAL.

Thanks

Capture.JPG

Hi @FRG ,

For your requirement, you could create the below measures to achieve your desired output.

minindex = CALCULATE(MIN('Table'[Index]),ALLEXCEPT('Table','Table'[No_PAL]))
Measure =
SUMX (
    FILTER (
        'Table',
        'Table'[Index] = [minindex]
            && 'Table'[No_PAL] = MAX ( 'Table'[No_PAL] )
    ),
    SUM ( 'Table'[Total] )
)

Here is the output.

Capture.PNG

Best Regards,

Cherry

 

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

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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