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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
MalyMajo
Frequent Visitor

Return last non-blank string value of ticket (probably) with LASTNONBLANK

I am struggling with getting only the last non blank value for each ticket.

In the Power Pivot measure, I have used a function LASTNONBLANK() , but the outcome was not reliable - probably because data model does not consider the original order of rows.
Excel formula or VBA is not an option and Power Query is not very efficient because of big load of data.

 

ticket step timestamp value
117/28/2021 04:15 PM 
127/28/2021 04:23 PMa
137/28/2021 04:30 PM 
147/28/2021 04:37 PMb
157/28/2021 04:44 PM 
167/28/2021 04:51 PM 
177/28/2021 04:59 PM 
217/29/2021 01:51 PMa
227/29/2021 02:49 PMb
237/29/2021 03:47 PMc
247/29/2021 04:44 PM 
257/29/2021 05:42 PMa
267/29/2021 06:39 PM 

 

For ticket "1", the returned value should be "b" (step 4) and for ticket "2", the returned value should be "a" (step 5).

ticket value
1b
2a
2 ACCEPTED SOLUTIONS
Jihwan_Kim
Super User
Super User

Picture1.png

 

Latest non blank value measure : =
VAR _lasttimestampnonblank =
CALCULATE ( MAX ( Data[timestamp] ), Data[value] <> BLANK () )
RETURN
IF (
HASONEVALUE ( Data[ticket] ),
CALCULATE ( VALUES ( Data[value] ), Data[timestamp] = _lasttimestampnonblank )
)
 
 

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.


Go to My LinkedIn Page


View solution in original post

Greg_Deckler
Super User
Super User

@MalyMajo Try: 

Measure 2 = 
    VAR __Table = FILTER('Table7',[value]<>"")
    VAR __Max = MAXX(__Table,[timestamp])
RETURN
    MAXX(FILTER(__Table,[timestamp] = __Max),[value])

@ 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

2 REPLIES 2
Greg_Deckler
Super User
Super User

@MalyMajo Try: 

Measure 2 = 
    VAR __Table = FILTER('Table7',[value]<>"")
    VAR __Max = MAXX(__Table,[timestamp])
RETURN
    MAXX(FILTER(__Table,[timestamp] = __Max),[value])

@ 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...
Jihwan_Kim
Super User
Super User

Picture1.png

 

Latest non blank value measure : =
VAR _lasttimestampnonblank =
CALCULATE ( MAX ( Data[timestamp] ), Data[value] <> BLANK () )
RETURN
IF (
HASONEVALUE ( Data[ticket] ),
CALCULATE ( VALUES ( Data[value] ), Data[timestamp] = _lasttimestampnonblank )
)
 
 

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.


Go to My LinkedIn Page


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.

Top Solution Authors