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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Summarize keeping only the last value for each id

Hello everyone, I'm trying to create a summarized table where I get the latest score for each item. 

 

My data is like this:

id_item      id_week

     score

11

90

12

70

13

80

21

40

22

60

33

30

 

And, with the use of summarize I would like to accomplish the following table:

id_item      id_week

       score

13

80

22

60

33

30

 

Where there is a row for each item and the score corresponding to the latest id_week that an item have.

 

Is it possible?

 

Thanks in advance

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Untitled.png

 

New table =
CALCULATETABLE (
    Data,
    TREATAS (
        GROUPBY (
            Data,
            Data[id_item],
            "@maxidweek", MAXX ( CURRENTGROUP (), Data[id_week] )
        ),
        Data[id_item],
        Data[id_week]
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new table.

 

Untitled.png

 

New table =
CALCULATETABLE (
    Data,
    TREATAS (
        GROUPBY (
            Data,
            Data[id_item],
            "@maxidweek", MAXX ( CURRENTGROUP (), Data[id_week] )
        ),
        Data[id_item],
        Data[id_week]
    )
)

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Thank you Jihwan, that's working perfectly.
I have another doubt, what would you new to modify if you would like to have another column in the original table showing the score value for of the latest week for each row?

e.g.

id_item id_weekscorelast_score for item
119080
127080
138080
214060
226060
333030

 

Thanks!

Hi,

thank you for your message.

If you want to create a new column in the table, please check the below picture and the attached pbix file.

It is for creating a new column.

 

Picture1.png

 

Last_week_score CC =
VAR _maxweeknumber =
    MAXX (
        FILTER ( Data, Data[id_item] = EARLIER ( Data[id_item] ) ),
        Data[id_week]
    )
RETURN
    SUMMARIZE (
        FILTER (
            Data,
            Data[id_item] = EARLIER ( Data[id_item] )
                && Data[id_week] = _maxweeknumber
        ),
        Data[score]
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Excelent! thank you very much again.

 

Have a nice day!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors