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
MarcS
Helper I
Helper I

Get KPI indicator by selected time period in comparison to time period before

Hi,

 

iam looking for a solution for the following problem:

 

The dashboard user can select a time periode over a data filter visualisation.

 

I have the following data set:

 

 

Now I will integrate a KPI indicator for the column "reach" in comparison with the time period before.

 

1st example:

User selection: 24.06.2017

Total reach: 189

Time period before: 23.06.2017

Total reach: 1062

- 82,21%

 

2nd. example:

 

User selection: 23.06.2017 - 24.06.2017

Total Reach = 1.251

Time period before: 21.06.2017 - 22.06.0217

Total reach = 1.495

- 16,33%

 

Iam using PowerBi Desktop v2.47.4766.801. Is this possible with a new measure and dax function?

 

Thanks a lot

2 ACCEPTED SOLUTIONS
TomMartens
Super User
Super User

Here is a little example

 

Basically I created two measures

reach within the selection

reachSelection = 
var minDateSelection = MINX(ALLSELECTED('reach'[date]),'reach'[date])
var maxDateSelection = MAXX(ALLSELECTED('reach'[date]),'reach'[date])
return
CALCULATE(SUM(reach[reach]),
	FILTER(ALL(reach[date]),
		'reach'[date] >= minDateSelection && 'reach'[date] <= maxDateSelection
	)
) 

reach < min(selection)

reachBeforeSelection = 
var minDateSelection = MINX(ALLSELECTED('reach'[date]),'reach'[date])
return
CALCULATE(SUM(reach[reach]),
	FILTER(ALL(reach[date]),
		'reach'[date] < minDateSelection
	)
)

Finally a division a little percent consideration

aKPI = (Divide([reachSelection],[reachBeforeSelection])-1)*100 

The second example looks like this

2017-07-05_19-32-04.png

 

But I have to admit that I have a different result for the first exmple ...

 

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

Hey,

 

try this measure 🙂

 

try this = 
var minDateSelection = MINX('statistics','statistics'[Date])
var numberOfDatesInSelection = DISTINCTCOUNT('reach'[date])
return
calculate(
	SUM(reach[reach]),	
	topn(numberOfDatesInSelection,
		FILTER(ALL(statistics),
			'statistics'[Date] <  minDateSelection
		),
	'statistics'[Date],
	DESC
	)
)

My previous solution did not use the last days (noofdays), now i determine these days and then i'm filtering the the reach table, guess it's fixed now (hopefully)



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

17 REPLIES 17

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.