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
acco
Frequent Visitor

problem with slicer and dynamic dates

Hi everyone, I'm quite new to Power BI (but I love it).
I've my data, that consist in a single table with lots of columns. The data rappresents the income, or better the insurance contracts paid by our customers. For each record there are several dates, two of them are used to filter the data (the date of end of cover of an insurance and the date corresponding the day a customer has paid).
I've imported only last 4 years of data.
Now I've created a slicer with YEARS and another one with MONTHS to dynamically show the data. I've to consider a special case about the running year cause it often happen that a customers pay an insurance which has just ended otherwise it will in the future, so, to compare income of the current year with the income, based on the same period, of last year. First of all I use MAX function to find the most recent day in which we have registered income. Based on that I set two dates: the starting day of actual year (the 01 january YYYY) and the "last payment day". With calculate() and sum(), filtering with datebetween() the two dates described before I obtain the total income for the year selected.
Now I would obtain the same total BUT for the previous year (so from 1st january YYYY-1) but I can not. The problem seems to be in passing the starting date, I've tried with date(), dateadd() but nothing to do, if I enter the date as a text string everything works as aspected but it can not be dynamically (if I choose one, or two, different years, the starting date has to be dynamically finded).
Any suggestion will be very appreciated.

ByeBye
Fabio

10 REPLIES 10

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.