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
ddurosier
Frequent Visitor

Working with Filters and Lastnonblank

Hi all, was hoping someone can quickly help because I've been trying to figure this out yesterday. I have some extra filters I want to add but just want a head start on how to get that going. Basically, I'm trying to do a filter to grab the latest comment of the ticket that's blank. My output should show for ticket T123 - the comment by Bob - "what is the status" instead of the one by Auto. Does that make sense?

 

Lastcomment = LASTNONBLANK( TableA[date], 1 ),

 

TABLE A   
ticketdateusernamecomment
T1235/4/2020bobwhat is the status
T1235/2/2020waldoinvestigating
T1234/29/2020bobplease see attachment
T1235/5/2020auto 
T1234/15/2020auto 
T3455/2/2020mikeCan I get an update
T3455/4/2020shawnneed more info
1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

maybe

 

VAR __last = MAXX(FILTER('Table',NOT(ISBLANK('Table'[comment])),[date])

RETURN

MAXX(FILTER('Table',[date]=__last),[comment])


@ 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

6 REPLIES 6
v-jayw-msft
Community Support
Community Support

Hi @ddurosier ,

 

Please check the formula below.

Measure = 
var maxdate = CALCULATE(MAX('Table'[date]),FILTER(ALL('Table'),'Table'[comment]<>BLANK()))
return
IF(SELECTEDVALUE('Table'[date])=maxdate,1,0)

Add this formula to visual filter and the result will be shown as below.

5.PNG

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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

For some reason this one I couldn't get it working.

amitchandak
Super User
Super User

@ddurosier , create a measure like this and use in analysis

Measure =
VAR __id = MAX ( 'Table'[ticket] )
VAR __date = CALCULATE ( MAX( 'Table'[date] ), ALLSELECTED ( 'Table' ), 'Table'[ticket] = __id , isblank(Table[comment]))
RETURN CALCULATE ( count ( 'Table'[ticket] ), VALUES ( 'Table'[ticket ), 'Table'[ticket] = __id, 'Table'[date] = __date )

Greg_Deckler
Super User
Super User

maybe

 

VAR __last = MAXX(FILTER('Table',NOT(ISBLANK('Table'[comment])),[date])

RETURN

MAXX(FILTER('Table',[date]=__last),[comment])


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

I was able to get the result with this. Now, if I wanted to add additional filters such as "if comment table contains this" or "only if reporter is this person etc.", how would I incorporate that to this measure? Is not a big deal but was just curious.

So,

 

VAR __last = 
  MAXX(
    FILTER(
      'Table',
      ( NOT(ISBLANK('Table'[comment]) || <some other condition> ) && <this condition also>
    ),
    [date]
  )
RETURN
  MAXX(FILTER('Table',[date]=__last),[comment])

 

It's just logic that you can string together with || for OR and && for AND and you can use parens ( ) to group things.


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

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.