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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
John343467
Helper I
Helper I

Last Date and Next Date.

Hi, 

 

I'm a little stuck with this one. 

 

I have the following table:

NameEventStartdateParticipated
JohnDavis Cup20.10.2020No
JohnFrench Open15.07.2020Yes
JohnWimbledon19.06.2020Yes
JohnUS Open20.02.2021No
BillDavis Cup20.10.2020Yes
BillFrench Open15.07.2020Yes
BillWimbledon19.06.2020Yes
BillUS Open20.02.2021No

 

And I would like the following result: 

 

NameLast Tournament ParticipationNext Tournament Participation
JohnFrench Open - 15.07.2020US Open - 20.02.2021
BillDavis Cup - 20.10.2020US Open - 20.02.2021

 

I need to write the event name in the last and next participation column, add the date and check for a yes for participation for the past events. I started by creating a simple measure trying to work out the last participation with calculate (max) of the startdate column but I'm a bit stuck here. 

 

Thanks for any help. 

2 ACCEPTED SOLUTIONS
littlemojopuppy
Community Champion
Community Champion

Worked this out in Excel/Power Pivot...

littlemojopuppy_0-1608233793342.png

 

Here are the measures

Last Tournment Participation Date:=CALCULATE(
		LASTNONBLANK(
			'Tournament Participation'[Startdate],
			TRUE()
		),
		FILTER(
			ALLEXCEPT(
				'Tournament Participation',
				'Tournament Participation'[Name]
			),
			'Tournament Participation'[Participated] = TRUE()
		)
	)

Last Tournment Participation:=CALCULATE(
		FIRSTNONBLANK(
			'Tournament Participation'[Event],
			TRUE()
		),
		FILTER(
			ALLEXCEPT(
				'Tournament Participation',
				'Tournament Participation'[Name]
			),
			'Tournament Participation'[Startdate] = [Last Tournment Participation Date]
		)
	)

Next Tournament Date:=CALCULATE(
		MIN('Tournament Participation'[Startdate]),
		FILTER(
			ALL('Tournament Participation'),
			'Tournament Participation'[Startdate] >= TODAY()
		)
	)

Next Tournament:=CALCULATE(
		FIRSTNONBLANK(
			'Tournament Participation'[Event],
			TRUE()
		),
		FILTER(
			ALLEXCEPT(
				'Tournament Participation',
				'Tournament Participation'[Name]
			),
			'Tournament Participation'[Startdate] = [Next Tournament Date]
		)
	)

View solution in original post

v-yiruan-msft
Community Support
Community Support

Hi @John343467 ,

You can create two measures as below:

Last Tournament Participation = 
VAR _lastpdate =
    CALCULATE (
        MAX ( 'Events'[Startdate] ),
        FILTER (
            ALL ( 'Events' ),
            'Events'[Name] = MAX ( 'Events'[Name] )
                && 'Events'[Participated] = "Yes"
        )
    )
VAR _lastpevent =
    CALCULATE (
        MAX ( 'Events'[Event] ),
        FILTER (
            ALL ( 'Events' ),
            'Events'[Name] = MAX ( 'Events'[Name] )
                && 'Events'[Participated] = "Yes"
                && 'Events'[Startdate] = _lastpdate
        )
    )
RETURN
    CONCATENATE ( CONCATENATE ( _lastpevent, " - " ), _lastpdate )
Next Tournament Participation = 
VAR _lastNpdate =
    CALCULATE (
        MAX ( 'Events'[Startdate] ),
        FILTER (
            ALL ( 'Events' ),
            'Events'[Name] = MAX ( 'Events'[Name] )
                && 'Events'[Participated] = "No"
        )
    )
VAR _lastNpevent =
    CALCULATE (
        MAX ( 'Events'[Event] ),
        FILTER (
            ALL ( 'Events' ),
            'Events'[Name] = MAX ( 'Events'[Name] )
                && 'Events'[Participated] = "No"
                && 'Events'[Startdate] = _lastNpdate
        )
    )
RETURN
    CONCATENATE ( CONCATENATE ( _lastNpevent, " - " ), _lastNpdate )

Last Date and Next Date.JPG

Best Regards

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

View solution in original post

9 REPLIES 9
v-yiruan-msft
Community Support
Community Support

Hi @John343467 ,

You can create two measures as below:

Last Tournament Participation = 
VAR _lastpdate =
    CALCULATE (
        MAX ( 'Events'[Startdate] ),
        FILTER (
            ALL ( 'Events' ),
            'Events'[Name] = MAX ( 'Events'[Name] )
                && 'Events'[Participated] = "Yes"
        )
    )
VAR _lastpevent =
    CALCULATE (
        MAX ( 'Events'[Event] ),
        FILTER (
            ALL ( 'Events' ),
            'Events'[Name] = MAX ( 'Events'[Name] )
                && 'Events'[Participated] = "Yes"
                && 'Events'[Startdate] = _lastpdate
        )
    )
RETURN
    CONCATENATE ( CONCATENATE ( _lastpevent, " - " ), _lastpdate )
Next Tournament Participation = 
VAR _lastNpdate =
    CALCULATE (
        MAX ( 'Events'[Startdate] ),
        FILTER (
            ALL ( 'Events' ),
            'Events'[Name] = MAX ( 'Events'[Name] )
                && 'Events'[Participated] = "No"
        )
    )
VAR _lastNpevent =
    CALCULATE (
        MAX ( 'Events'[Event] ),
        FILTER (
            ALL ( 'Events' ),
            'Events'[Name] = MAX ( 'Events'[Name] )
                && 'Events'[Participated] = "No"
                && 'Events'[Startdate] = _lastNpdate
        )
    )
RETURN
    CONCATENATE ( CONCATENATE ( _lastNpevent, " - " ), _lastNpdate )

Last Date and Next Date.JPG

Best Regards

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

@v-yiruan-msft Brilliant, thank you. Just a few little points.

1. I've noticed that I've some events in the future that have yes for Participation listed (it's a mistake in the data), how could I get around this so that for Last Tournament Participation, these events are not shown and only the ones in the past are shown? 

 

2. If I just wanted the event and not the date to show in the last event participation column, what should the DAX be for the last line. 

 

Thanks again, much appreciated. 

littlemojopuppy
Community Champion
Community Champion

Worked this out in Excel/Power Pivot...

littlemojopuppy_0-1608233793342.png

 

Here are the measures

Last Tournment Participation Date:=CALCULATE(
		LASTNONBLANK(
			'Tournament Participation'[Startdate],
			TRUE()
		),
		FILTER(
			ALLEXCEPT(
				'Tournament Participation',
				'Tournament Participation'[Name]
			),
			'Tournament Participation'[Participated] = TRUE()
		)
	)

Last Tournment Participation:=CALCULATE(
		FIRSTNONBLANK(
			'Tournament Participation'[Event],
			TRUE()
		),
		FILTER(
			ALLEXCEPT(
				'Tournament Participation',
				'Tournament Participation'[Name]
			),
			'Tournament Participation'[Startdate] = [Last Tournment Participation Date]
		)
	)

Next Tournament Date:=CALCULATE(
		MIN('Tournament Participation'[Startdate]),
		FILTER(
			ALL('Tournament Participation'),
			'Tournament Participation'[Startdate] >= TODAY()
		)
	)

Next Tournament:=CALCULATE(
		FIRSTNONBLANK(
			'Tournament Participation'[Event],
			TRUE()
		),
		FILTER(
			ALLEXCEPT(
				'Tournament Participation',
				'Tournament Participation'[Name]
			),
			'Tournament Participation'[Startdate] = [Next Tournament Date]
		)
	)

@littlemojopuppy Thank you very much. Just checking the last Tournament participation measure. For the last line, I get the message, cannot find name Last Tournment Participation Date. Thanks again. Much appreciated. 

"Last Tournment Participation Date" is one of the measures from above...you added all of them?

littlemojopuppy
Community Champion
Community Champion

You don't want to use a column...use measures.  Calculated columns should be avoided.

 

Can't cut and paste a picture to work with the data.

Ok, updated the data to tables. Thanks. 

littlemojopuppy
Community Champion
Community Champion

You should be able to accomplish the most recently participated with LASTNONBLANK() filtering for where participated is true.  Next participated should be the name of the next tournament with the lowest date after today right?

Without data to work with hard to provide the exact measure

@littlemojopuppy Ok but the data is in the table above. Is it visible for you?

I started with this as a new column but this just gives me the last date in the table. CALCULATE ( MAX ('Table'[Startdate].[Date]), ALLEXCEPT( 'Table',Table [Name] ) )

Thanks. 

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.