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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Maryam_Pour
Frequent Visitor

How do I get the last item related to a specific value

Hi,
I have a matrix table that contains two columns.
A reference no. is the same for all mails in each mail thread, and the mail numbers change every time somebody replay or forwards the mail.

Maryam_Pour_0-1642601426288.png


The view that I,m trying to create is this one:

Maryam_Pour_1-1642601441644.png


So the Reference no. and the last email in the thread will be in one row, plus the count of all emails related to this reference number.

I've added Email numbers under the Values for Matrix table and selected the LAST, but it doesn't show me the last email number.
What do I do?


I hope you can help me to solve this issue.

 

6 REPLIES 6
HotChilli
Super User
Super User

"when there are many emails in the mail thread, I get another mail number but not the last one."

can you provide the reference numbers for an email which shows this please.  Just enough to illustrate this please (i.e. not 500 references!)

Fowmy
Super User
Super User

@Maryam_Pour 

Use two measures.


LAST EMAIL NO = MAX ( TABLENAME[EAMIL NUMBER] )
COUNT OF EMAILS = COUNTA( TABLENAME[EAMIL NUMBER] )

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

I have a big table with many reference numbers and many emails related to each of these reference numbers.
I'm not seeing how I can get the last email for each reference number in your solution.

HotChilli
Super User
Super User

"it doesn't show me the last email number" - what does it show?

In some cases, when there are a few emails in the mail thread, I get the last email and reference number in one row. But when there are many emails in the mail thread, I get another mail number but not the last one.

Hi @Maryam_Pour ,

 

Maybe you do some filters to this page where the matrix table is by slicer or filter pane.You can use ALLEXCPET() to to remove other filter context on this measure. Some code like the following.

Last =
CALCULATE(
    LASTNONBLANK( 'Table'[Email Number], 0 ),
    ALLEXCEPT( 'Table', 'Table'[Reference Number] )
)

If this does not work well, creating a index column maybe another choice.Please refer code below.

Last_index =
VAR _index =
    CALCULATE(
        MAX( 'Table'[Index] ),
        ALL( 'Table' ),
        'Table'[Reference Number] = SELECTEDVALUE( 'Table'[Reference Number] )
    )
RETURN
    CALCULATE( MAX( 'Table'[Email Number] ), 'Table'[Index] = _index )

 

Best Regards

Community Support Team _ chenwu zhu

 

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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.