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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
DKwustl
New Member

Displaying the latest date with comment correctly

I am having issues with a tracking report I have created. The data looks like the following within the database:

 

Item TypeEvent TimeUserCommentWorkstation
Slide A1/4/23 12:37pmJaneDelieveredW340
Draft1/4/23 11:23amJanePut in drop box

W340

Slide B1/4/23 10:02Julie W503
Slide A1/4/23 10:01amJulieSent to LabW503

 

Info about the tracking system. The latest comment always appears at the time and all types are tracked under the same database table. We do not care about infomation of the user or the work station. Whether it is a slide or draft, we want the lastest comment to diplay.

 

The table visual in the report has other identifying information with joined tables. It is a direct query. It looks like the following:

Case No.StatusCase opened datePriorityLast scan status(Comment)Last Scan date(Event time)
s-1Grossing1/2/23 9:00am2Put In Mailbox1/3/23 12:00pm
s-4Complete1/1/23 9:17am1With Doctor1/3/23 2:30pm
s-34Grossing1/3/23 9:13am3Sent to Lab1/3/23 10:23am

 

So we do not want to show any blank comments so I removed blanks or null from the filter. Cases have multiple status but we only want to show the lastest status date with a comment. What I am running into is sometimes the table does not show the latest date and comment. Since the system puts the latest comment on the first row, I aggregated "Last scan status" to show the first comment and the "last scan date" to show the latest time. 

 

The gets it so that there is only one line per case on the table. If I do dont summarize, it gives all the scans on one case. We do not want that. But the case just randomly will not show the correct "last scan status" but it will show the "latest scan date." Is there a way to create a formula to display this information correctly and accurately. I have tried everything I can think of and have had no success. I checked my SQL query to just confirm there was no issues there and that was fine.

 

I appreciate the help.

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@DKwustl Maybe:

Last scan status measure = 
  VAR __LastScanDate = MAX('Table',[Event Time])
  VAR __LastStatus = MAXX(FILTER('Table',[Event Time] = __LastScanDate),[Comment])
RETURN
  __LastScanDate

@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@DKwustl Maybe:

Last scan status measure = 
  VAR __LastScanDate = MAX('Table',[Event Time])
  VAR __LastStatus = MAXX(FILTER('Table',[Event Time] = __LastScanDate),[Comment])
RETURN
  __LastScanDate

@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

I feel like this is working but I want to make sure with todays results. I still had one that did not display the correct comment. It makes me feel it could be a scanning issue.

I feel like I attempted this one but let me try again just to be sure.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.