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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Anonymous
Not applicable

In Date Parameter, user Should not be able to select 'To date' lesser/before than 'from date' in Pag

I have configured the 'from date' and the 'to date' parameters in Paginated report. The report works fine.

 

I want to introduce a constraint/requirement that the use should not select a 'to date' which is before the 'from date'. Eg., if the from date is 10-Oct-@2023, the user can only select a 'to date' from 11-Oct-2023 onwards, the user should not be able to select 09-Oct-2023 or any previuous dates.

6 REPLIES 6
Anonymous
Not applicable

Hi Tech Community,

 

Has anyone been able to apply such a feature in your report?

 

I have applied the above method, but unable to get it resolved.

 

Sivaranjan_1-1699234884793.png

 

Help would be appreciated.

Anonymous
Not applicable

Hi Tech Community,

 

I got the solution and it works by throwing and error message when the From Date is after To Date. Solution is that : the From Date and To date has to be selected in the Filters in Dataset Properties as shown below.

Sivaranjan_1-1700201470323.png

 

 

 

Anonymous
Not applicable

This issue is still open, has anyone resolved a similar issue ?

devesh_gupta
Super User
Super User

@Anonymous You can try these steps:

  1. In the "Parameter Properties" window, go to the "Default Values" tab.
  2. For "To Date," you can set the "Default values" based on the "From Date" parameter. This will ensure that the "To Date" is always greater than or equal to the "From Date."
  3. Select "Specify values."
  4. Click the "Add" button.
  5. In the "Value" field, use an expression to set the "To Date" default value to one day after the "From Date." This can be done using an expression like:

 

=DateAdd(DateInterval.Day, 1, Parameters!FromDate.Value)
​

 

  • This expression adds one day to the selected "From Date," effectively making the "To Date" at least one day after the "From Date."

 

If you find this insightful, please provide a Kudo and accept this as a solution.

Anonymous
Not applicable

Hi Devesh_gupta,

Thank you so much for the help but I could not get it to work.

I tried 2 methods : 

1. created 2 Parameters as StartDate and EndDate in the Parameters on the top left

2. In StartDate I selected 'no default value' under DefaultValues

3. In End Date I selected 'Speficyvalues' under DefaulValues, selected add and entered the code "=DateAdd(DateInterval.Day, 1, Parameters!StartDate.Value)"

4. Under dataset where I have my dataset as SQL_Data, I have not made any config for date parameters.............. Then I select the 'to date' before the 'from date', the report runs but it brings data from another data from previous year. (Ideally I think the report should not run at all).

 

Method 2

under dataset-SQL_Data-> under filters->Add->expression-> select the date field

operator-> between. Then under value i selected StartDate. Then in the next box ->fx-> added =DateAdd(DateInterval.Day, 1, Parameters!StartDate.Value)..... The I run the report by selecting 'to date' before the 'from date'. This method does not get any data but report runs succesfully with no data in the report.

                                               Can you please help find what I am doign incorrectly , 

Anonymous
Not applicable

@devesh_gupta some week ago i resolved it.

 

Steps to resolve: 

under dataset-SQL_Data-> under filters->Add->expression-> select the date field

operator-> between. Then under value I selected [@StartDate]. Then in the next box ->fx-> I selected =Parameters!StartDate.Value. Similarly I selected [@EndDate] and in the fx-> I selected =Parameters!EndDate.Value

This works.

Sivaranjan_1-1701438825301.png

@devesh_gupta  thank you so much as you made the basic structure.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

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

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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