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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

pass N from LAst N days relative slicer to a measure to count users who DID NOT log in to system

Hi,

I want to use a filter  some way to allow users to select the value for N and filter the measure accordingly:

caculate(count(users),date<=today()-N)

where i want N to be a parameter that can be supplied by user.

If ,the KPI is count of users who accessed system in Last N days,its simple,i use relative slicer and change the N and measure gets filtered accorndingly.Since,it is the negation,i need think i cant say filter/slicer and then do the opposite calculation in the measure.

If it is not possible,am i left with the only way to create measures for each requirement; one for last 7 days,one for last 30 days and so on

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

To let people select a value of N, create a disconnected parameter table that will store all the values of N you're interested in. This table will be used as a slicer. Then create this measure:

 

[# Users] =
var __today = TODAY()
var __dayOffset = SELECTEDVALUE( ParameterTable[DayOffset] )
var __endDate = __today - __dayOffset
var __numOfUsers =
	CALCULATE(
		COUNTROWS( Users )
		DateTable[Date] <= __endDate
	)
return
	__numOfUsers

If nothing is selected from ParameterTable, __endDate will be equal to TODAY(). For the above to work, you have to have a DateTable that is a proper Date table in the model.

 

Best
Darek

View solution in original post

1 REPLY 1
Anonymous
Not applicable

To let people select a value of N, create a disconnected parameter table that will store all the values of N you're interested in. This table will be used as a slicer. Then create this measure:

 

[# Users] =
var __today = TODAY()
var __dayOffset = SELECTEDVALUE( ParameterTable[DayOffset] )
var __endDate = __today - __dayOffset
var __numOfUsers =
	CALCULATE(
		COUNTROWS( Users )
		DateTable[Date] <= __endDate
	)
return
	__numOfUsers

If nothing is selected from ParameterTable, __endDate will be equal to TODAY(). For the above to work, you have to have a DateTable that is a proper Date table in the model.

 

Best
Darek

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.