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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

How do I pass dates from a page-level filter to a measure?

I have a memberships table:

membership_id      membership_start      membership_end      user_id       
101-01-202131-12-2021a
201-06-202131-12-2021b
301-01-202231-12-2022c
401-01-202331-12-2023d

And a users table

user_id       account_created       city            

a

01-02-2020Austin
b02-02-2021Austin
c03-03-2021Seattle
d04-04-2020Chicago

 

I want to create a bar chart consisting of "count of active users, by city" in a given date range. I want to be able to change this date range as a page-level filter. (Multiple charts should get affected if I change this date range)
Lets assume the date range is date_range_start to date_range_end

I would consider a user as active if:

1. membership has started before the date_range_end, and ends after the date_range_start

 

(membership_start <= date_range_end) && (membership_end >= date_range_start)

 

 OR
2. account_created is between the date range

 

(account_created > date_range_start) && (account_created < date_range_end)

 


So If I select the date range as (06-06-2020 to 06-06-2021), I would get a joined table like this, along with a measure calculated with above conditions:

membership_id       user_id       membership_start       membership_end      account_created       city       is_active       

1

a01-01-202131-12-202101-02-2020AustinTRUE (satisfies 1st cond.)
2b01-06-202131-12-202102-02-2021AustinTRUE (satisfies 1st cond.)
3c01-01-202231-12-202203-03-2021SeattleTRUE (satisfies 2nd)
4d01-01-202331-12-202304-04-2020ChicagoFALSE

 

I was able to do this by creating a measure that satisfies above conditions. But I am not able to add a page-level filter on the measure is_active to choose only the rows where is_active = TRUE.

 

I need the resulting table to be:

membership_id       user_id       membership_start       membership_end       account_created       city       is_active       

1

a01-01-202131-12-202101-02-2020AustinTRUE (satisfies 1st cond.)
2b01-06-202131-12-202102-02-2021AustinTRUE (satisfies 1st cond.)
3c01-01-202231-12-202203-03-2021SeattleTRUE (satisfies 2nd)

So that I would create a bar chart using "city" on x-axis, and "count of city" on y-axis, for the selected date range. (Of course, I should be able to change the date-range, which in turn changes the charts)

 

Is there a way to get the resulting table like above, while getting the date-range as user input?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

I made simple samples and you can check the results below:

vtianyichmsft_0-1710297192929.png

Measure = var _max = MAX('Table 2'[Date])
var _min = MIN('Table 2'[Date])
RETURN IF(MAX('Table'[membership_start       ])<=_max&&MAX('Table'[membership_end      ])>=_min,1,IF(MAX('Table'[account_created       ])>_min&&MAX('Table'[account_created       ])<_max,2,0))


 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous ,

 

I made simple samples and you can check the results below:

vtianyichmsft_0-1710297192929.png

Measure = var _max = MAX('Table 2'[Date])
var _min = MIN('Table 2'[Date])
RETURN IF(MAX('Table'[membership_start       ])<=_max&&MAX('Table'[membership_end      ])>=_min,1,IF(MAX('Table'[account_created       ])>_min&&MAX('Table'[account_created       ])<_max,2,0))


 

An attachment for your reference. Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

lbendlin
Super User
Super User

Not really a need for that as it is part of the filter context that the measure operates in.  If you must, use VALUES()  or FILTERS().

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors