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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
LFM
Helper I
Helper I

Finding delta between certain dates while filtering the dates

I want to find the change of values between dates while filtering between dates on the slicer. F.eks I want to choose the dates 01.02.2024 and 15.02.2024 on the slicer and then see the delta value between those dates.
I have tried the DAX measure shown below, but it will only show values for certain days back in time, and I cannot filter between different dates. 

Exposure report date.pngPrevious month exposure.pngDelta exposure.png

1 ACCEPTED SOLUTION
v-zhengdxu-msft
Community Support
Community Support

Hi @LFM 

 

Please try this:
First of all, I create a set of sample:

vzhengdxumsft_0-1712887273778.png

Then add a measure:

Diff = 
	VAR _currentDate = CALCULATE(
		MAX('Table'[Date]),
		ALLSELECTED('Table')
	)
	VAR _previousDate = CALCULATE(
		MIN('Table'[Date]),
		ALLSELECTED('Table')
	)
	RETURN
		CALCULATE(
			SUM('Table'[Values]),
			FILTER(
				ALLSELECTED('Table'),
				'Table'[Date] = _currentDate
			)
		) - CALCULATE(
			SUM('Table'[Values]),
			FILTER(
				ALLSELECTED('Table'),
				'Table'[Date] = _previousDate
			)
		)

The result is as follow:

vzhengdxumsft_1-1712887346711.pngvzhengdxumsft_2-1712887358399.png

Best Regards

Zhengdong Xu
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

1 REPLY 1
v-zhengdxu-msft
Community Support
Community Support

Hi @LFM 

 

Please try this:
First of all, I create a set of sample:

vzhengdxumsft_0-1712887273778.png

Then add a measure:

Diff = 
	VAR _currentDate = CALCULATE(
		MAX('Table'[Date]),
		ALLSELECTED('Table')
	)
	VAR _previousDate = CALCULATE(
		MIN('Table'[Date]),
		ALLSELECTED('Table')
	)
	RETURN
		CALCULATE(
			SUM('Table'[Values]),
			FILTER(
				ALLSELECTED('Table'),
				'Table'[Date] = _currentDate
			)
		) - CALCULATE(
			SUM('Table'[Values]),
			FILTER(
				ALLSELECTED('Table'),
				'Table'[Date] = _previousDate
			)
		)

The result is as follow:

vzhengdxumsft_1-1712887346711.pngvzhengdxumsft_2-1712887358399.png

Best Regards

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

 

 

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors