cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
anthon
Frequent Visitor

Filter a table by highest column value

Hello!

 

I have a dataset that is looking something like this:

 

ServerScanid
Server11
Server22
Server3

1

Server1

3

Server2

3

How can I make a DAX query the only filters out the servers in the last Scanid?

 

In this example I would like to return:

ServerScanid
Server13
Server23
2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi, @anthon 

Please check the below, whether it is what you are looking for.

 

Picture2.png

 

ScanID Measure =
VAR lastscanidoverall =
MAXX ( ALL ( 'Table' ), 'Table'[Scanid] )
VAR currentscanid =
MAX ( 'Table'[Scanid] )
RETURN
IF (
ISFILTERED ( 'Table'[Server] ),
IF ( lastscanidoverall = currentscanid, currentscanid )
)

 

 

https://www.dropbox.com/s/093gm8gkoidowoq/anthon.pbix?dl=0 

 

 

Hi, My name is Jihwan Kim.

 

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

 

Linkedin: linkedin.com/in/jihwankim1975/

Twitter: twitter.com/Jihwan_JHKIM


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

Best regards, JiHwan Kim

Linkedin: https://www.linkedin.com/in/jihwankim1975/

Twitter: https://twitter.com/Jihwan_JHKIM

Greg_Deckler
Super User
Super User

@anthon I call this the Complex Selector. https://community.powerbi.com/t5/Quick-Measures-Gallery/The-Complex-Selector/td-p/1116633

 

Basically, create a measure like the following and use it in the Filter pane or you could also do it as a column:

Measure Selector =
  VAR __Max = MAXX(ALL('Table'),[ScanID])
  VAR __Current = MAX('Table'[ScanID])
RETURN
  IF(__Current = __Max,1,0)


Column Selector
  VAR __Max = MAX('Table'[ScanID])
  VAR __Current = [ScanID]
RETURN
  IF(__Current = __Max,1,0)

 


@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop!
Microsoft Hates Greg's Quick Measures
Check out my latest book!

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!