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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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.

 

 


@ 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!:
The Definitive Guide to Power Query (M)

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
v-shex-msft
Community Support
Community Support

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

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
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
Super User
Super User

@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.


@ 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!:
The Definitive Guide to Power Query (M)

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.

 

 


@ 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!:
The Definitive Guide to Power Query (M)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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