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
Alejandro
Regular Visitor

Different date periods with a Between Calendar Filter

Hello,

I need your help. I have been trying lots of things, but I could not manage to get what I want to:

 

I have this Between Calendar Filter in my report, but I want the widgets to behavior a bit different:

 

PowerBI Issue.png 

 

 

  • The "Card" ones are working fine, just want to calculate the measure between the filter dates.
  • At the Bar chart I want to display the period FROM: Last selected date -13 months TO: Last Selected date. (Keeping the monthly granularity). That is the point that I am not achieving.

 

Could you help me?

Thanks a lot

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@Alejandro,

Please create a date table using DAX below. Ensure that there is no relationship between the date table and your original table.

date = CALENDARAUTO()


Create the following measure in your original table, and then use the date field of date table to create a slicer.

Last 13 month = var Ldate=MAX('date'[Date])
var Fdate=date(year(edate(Ldate,-13)),month(edate(Ldate,-13)),1)
return  IF(MIN('Yourtable'[DateKey])<Fdate,BLANK(),IF(MIN('Yourtable'[DateKey])>Ldate,BLANK(),yourcalculation))


There is a similar thread for your reference.
https://community.powerbi.com/t5/Desktop/Show-last-13-months-based-on-user-single-slicer-selection/t...

Regards,
Lydia

Community Support Team _ Lydia Zhang
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
v-yuezhe-msft
Employee
Employee

@Alejandro,

Please create a date table using DAX below. Ensure that there is no relationship between the date table and your original table.

date = CALENDARAUTO()


Create the following measure in your original table, and then use the date field of date table to create a slicer.

Last 13 month = var Ldate=MAX('date'[Date])
var Fdate=date(year(edate(Ldate,-13)),month(edate(Ldate,-13)),1)
return  IF(MIN('Yourtable'[DateKey])<Fdate,BLANK(),IF(MIN('Yourtable'[DateKey])>Ldate,BLANK(),yourcalculation))


There is a similar thread for your reference.
https://community.powerbi.com/t5/Desktop/Show-last-13-months-based-on-user-single-slicer-selection/t...

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

I am thinking that you are going to have to disconnect your date slicer from that visual. Then, you could theoretically adjust your measure to do something like:

 

Measure = 
VAR __maxDate = MAX('Table'[Date]) //get the latest date in your slicer
VAR __minDate = DATE(YEAR(__maxDate)-1,MONTH(__maxDate)-1,DAY(__maxDate)) //approximately 13 months, probably a better way to do this but this is for an example.
VAR __table = FILTER('Table1','Table1[Date]>=__minDate && 'Table1[Date]<=__maxDate //create a filtered temp table
RETURN
//Do measure calculation stuff here based on your temp table.

OK, I don't have your measure formula so can't be more specific. But, in theory, this should only return a value for the measure for your desired date range.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.