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
Anonymous
Not applicable

Filter based on date selected and MTD/YTD

Hello guys,

 

Here is the problem I am facing.
I have a table with dates and multiple transactions per day.
I need to create a report where the user can select a specific date and a period (either MTD ither YTD).

Based on these two parameters, I should filter all the dates included in this time period.
For instance, if the user selects 15/04/2020 and MTD, it should filter and keep all the values between 01/04/2020 and 15/04/2020 in all the visuals of the report.


How can I do this filter based on these user-selected parameters ?

 

Thanks a lot for your help ! I hope the definition of the problem is clear.

 

Cheers,

 

Jay 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1597312585957.png

 

Best regards,
Lionel Chen

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

8 REPLIES 8
v-lionel-msft
Community Support
Community Support

Hi @Anonymous ,

 

Maybe my .pbix file can help you.

v-lionel-msft_0-1597053356889.png

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

@v-lionel-msft The MTD is now working, I had to adapt it but it works.

 

What I need to correct now is that the YTD is actually based on the fiscal year, starting 1st of April and not 1st of Jan. How can I do that ?

Hi @Anonymous ,

 

Please refer to my .pbix file.

v-lionel-msft_0-1597312585957.png

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

@v-lionel-msft Can you explain me the logic behind the calculation of _min_date_by_year ? 
I don't get it at atll.

 

Thanks a lot for your help !!

Hi @jejenial,

v-lionel-msft_0-1597396762884.png

Condition 1:

I assume that your financial year starts in April, such as (4/1/2019~3/1/2020), (4/1/2020~3/1/2021), (4/1/2021~3/1/2022)... So I marked all the dates in April.

Condition 2:

Condition 2 is to ensure that the date obtained is the date of the current financial year.

v-lionel-msft_1-1597396947930.png

In addition, MAX() here is equivalent to EARLIER().

Can the solution solve your problem?

Best regards,
Lionel Chen

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

Hi @Anonymous ,

 

Has your problem been solved?

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

Hello @v-lionel-msft,

Thanks for your answer which helps already a lot.

The YTD works perfectly but the MTD does not and I don't know why.

 

Also, could you explain me the reason behind that line of code : 

FILTER( ALL('calendar'), 'calendar'[Date].[Year] = MAX('calendar'[Date].[Year]) ) 

 

Why do you use MAX ?

 

Thanks,

Jerome

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.