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

The Fabric Community site will be in read-only mode on Monday, Feb 24 from 12:01 AM to 8 AM PST for scheduled upgrades.

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.