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
pkoel-asb
Helper V
Helper V

Apply a date value (currently held in a measure) to whole report

Hello,

 

   I want to allow the report user to select a date range. I created a measure to hold the user's selection. the code is below:

rptStrDate =
var x = max('Calendar'[Date])
var Startdate =
         switch(SELECTEDVALUE(TimePeriodFilter[SelectTiime]),
            "Year to Date", date(year(x), 1,1),
            "Rolling 12 Months", date(year(x),Month(x)-12,day(x)),
            "Last Year", date(year(x)-1,1,1),
            "All Data", date(2019,1,1))
return Startdate
 
How do I take the date value stored in rptStrDate and filter the whole report by it? I am unable to put the measure name in the filter box for Filters on all pages.
 
Cheers!
1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @pkoel-asb 

Thanks for reaching out to us.

>> How do I take the date value stored in rptStrDate and filter the whole report by it?  I am unable to put the measure name in the filter box for Filters on all pages.

you can only put field from the Fields pane into report-level filter

vxiaotang_0-1656577112250.png

so as an workaround, you can set filter for each visual, for example, [rptStrDate] will return the date selected, then you can use it to filter the report by visual-level filter, Add a filter to a report in Power BI - Power BI | Microsoft Docs

vxiaotang_0-1656310716673.png

create a filter measure,  filter= if(min('tabletobefilterd'[date])<[rptStrDate],1), then put [filter] into visual-level filter of the visual, then set 1 and apply.

Or 

you can set a date slicer and use ALLSELECTED() function, i.e. you can use sync slicer +Allselected() function, then you will get date filtered on all pages. Slicers in Power BI - Power BI | Microsoft Docs

 

Best Regards,

Community Support Team _Tang

If this post helps, 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-xiaotang
Community Support
Community Support

Hi @pkoel-asb 

Thanks for reaching out to us.

>> How do I take the date value stored in rptStrDate and filter the whole report by it?  I am unable to put the measure name in the filter box for Filters on all pages.

you can only put field from the Fields pane into report-level filter

vxiaotang_0-1656577112250.png

so as an workaround, you can set filter for each visual, for example, [rptStrDate] will return the date selected, then you can use it to filter the report by visual-level filter, Add a filter to a report in Power BI - Power BI | Microsoft Docs

vxiaotang_0-1656310716673.png

create a filter measure,  filter= if(min('tabletobefilterd'[date])<[rptStrDate],1), then put [filter] into visual-level filter of the visual, then set 1 and apply.

Or 

you can set a date slicer and use ALLSELECTED() function, i.e. you can use sync slicer +Allselected() function, then you will get date filtered on all pages. Slicers in Power BI - Power BI | Microsoft Docs

 

Best Regards,

Community Support Team _Tang

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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.