DAX: Return column corresponding to LastDate

DateWrangle

New Member
Joined
May 4, 2017
Messages
2
Hi All

I am pretty fluent with Excel but I am still getting to grips with DAX and I am struggling to come up with the correct DAX formula for what should be a simple Measure.

I have a number of connected Tables in PowerPivot. The table I wish to apply a measure to is a table called MailingHistory, which is formatted as follows:

[TABLE="width: 580"]
<tbody>[TR]
[TD]
ContactID​
[/TD]
[TD]
MailingDescription​
[/TD]
[TD]
MailingDate​
[/TD]
[/TR]
[TR]
[TD]
123456​
[/TD]
[TD]
Spring Mailing 2017​
[/TD]
[TD]
01/042017​
[/TD]
[/TR]
[TR]
[TD]
456789​
[/TD]
[TD]
Spring Mailing 2017​
[/TD]
[TD]
01/042017​
[/TD]
[/TR]
[TR]
[TD]
789123​
[/TD]
[TD]
Winter Mailing 2016​
[/TD]
[TD]
01/12/2017​
[/TD]
[/TR]
[TR]
[TD]
654130​
[/TD]
[TD]
Winter Mailing 2016​
[/TD]
[TD]
01/12/2017​
[/TD]
[/TR]
[TR]
[TD]
927231​
[/TD]
[TD]
Autumn Mailing 2016​
[/TD]
[TD]
01/09/2016​
[/TD]
[/TR]
[TR]
[TD]
789123​
[/TD]
[TD]
Autumn Mailing 2016​
[/TD]
[TD]
01/09/2016​
[/TD]
[/TR]
</tbody>[/TABLE]

I am able create a measure detailing the Last Mailing Date by using the DAX formula Last Mailing Date:=LASTDATE(MailingHistory[MailingDate]).

What has me scratching my head is how to create a measure that returns the MailingDescription corresponding to the Last Mailing Date.

I suspect that there is an easy way to return this value, but thus far the solution has eluded me despite my best efforts and I'd be very grateful if anyone could advise.

Many thanks!
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I can think of a couple ways to do this. Given limited info, this will work:

Code:
Last MailingDescription := CALCULATE ( LASTNONBLANK(MailingHistory[MailingDate],1), [Last Mailing Date] )

But may break down if you have slicers or items in rows/columns.

I added the "LASTNONBLANK" part in case more than one value is possible on the LASTDATE.
 
Upvote 0
I can think of a couple ways to do this. Given limited info, this will work:

Code:
Last MailingDescription := CALCULATE ( LASTNONBLANK(MailingHistory[MailingDate],1), [Last Mailing Date] )

But may break down if you have slicers or items in rows/columns.

I added the "LASTNONBLANK" part in case more than one value is possible on the LASTDATE.

Many thanks for the help, I got it working with a variation of what you suggested, specifically:

Last Mailing Description:= CALCULATE (LASTNONBLANK(MailingHistory[MailingCodeDescription],[Last Mailing Date]))
 
Upvote 0

Forum statistics

Threads
1,225,741
Messages
6,186,763
Members
453,370
Latest member
juliewar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top