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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
FilipK
Resolver I
Resolver I

Get last value in group

Hey,

 

assume you've got this dataset:

timedeviceIdVersion
7/29/20211A
7/30/20211A
7/31/20212A
8/1/20212A
8/2/20213C
8/3/20211B
8/4/20212A
8/5/20211B
8/6/20211B
8/7/20212B
8/8/20213B
8/9/20211B
8/10/20212D
8/11/20211B

 

And all what you want to do is to create a table and a pie chart, that depicts the latest distribution of versions among the devices.

 

Desired table is like this:

 

timedeviceIdVersion
8/2/20213B
8/10/20212D
8/11/20211B

 

And counted like this:

VersionCount of Version (only latest per device considered)
A0
B2
C0
D1

 

A pie chart is needed for the latter table.

How would you solve it?

 

 

 

3 ACCEPTED SOLUTIONS

@FilipK This will return your first desired table:

 

 

Table 2 = 
    VAR __Table = SUMMARIZE('Table (5)',[deviceId],"__time",MAX('Table (5)'[time]))
    VAR __Table2 = ADDCOLUMNS(__Table,"__Version",MAXX(FILTER('Table (5)','Table (5)'[deviceId] = [deviceId] && [time] = [__time]),[Version]))
RETURN
    __Table2

 

You can use this in a measure like the following:

Measure = 
    VAR __Version = MAX([Version])
    VAR __Table = SUMMARIZE(ALL('Table (5)'),[deviceId],"__time",MAX('Table (5)'[time]))
    VAR __Table2 = ADDCOLUMNS(__Table,"__Version",MAXX(FILTER('Table (5)','Table (5)'[deviceId] = [deviceId] && [time] = [__time]),[Version]))
RETURN
    COUNTROWS(FILTER(__Table2,[__Version] = __Version)) + 0

This would be used in a pie chart along with your [Version] column for example.

 

 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

@FilipK 

pls see the atatchment below

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @FilipK,

Did the above suggestions help with your scenario? if that is the case, you can consider Kudo or accept the helpful suggestions to help others who faced similar requirements to find it more quickly.

If these also don't help, please share more detailed information to help us clarify your scenario to test.

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Community Champion
Community Champion

@FilipK Seems like Lookup Min/Max to me. https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434

 

For the first table, that seems like a straight MAX measure for the time column in that table. Then just use that to figure out the Version at that time.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler , I think it's another case. But I suppose you proposed that solution since in my the first version of the post, I made a fault in the expected output tables. Sorry for that. I corrected myself already.

 

My idea is: Get the last time each device sent a message and based on that outcome summarize the versions. At this point I've struggled.

@FilipK This will return your first desired table:

 

 

Table 2 = 
    VAR __Table = SUMMARIZE('Table (5)',[deviceId],"__time",MAX('Table (5)'[time]))
    VAR __Table2 = ADDCOLUMNS(__Table,"__Version",MAXX(FILTER('Table (5)','Table (5)'[deviceId] = [deviceId] && [time] = [__time]),[Version]))
RETURN
    __Table2

 

You can use this in a measure like the following:

Measure = 
    VAR __Version = MAX([Version])
    VAR __Table = SUMMARIZE(ALL('Table (5)'),[deviceId],"__time",MAX('Table (5)'[time]))
    VAR __Table2 = ADDCOLUMNS(__Table,"__Version",MAXX(FILTER('Table (5)','Table (5)'[deviceId] = [deviceId] && [time] = [__time]),[Version]))
RETURN
    COUNTROWS(FILTER(__Table2,[__Version] = __Version)) + 0

This would be used in a pie chart along with your [Version] column for example.

 

 



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
ryan_mayu
Super User
Super User

@FilipK 

why deviceID 3 is not B on 8/8/2021?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu , oh. Absolutely right. I've just edited.

@FilipK 

pls see the atatchment below

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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