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

Date Selection Slicer

Good Morning All!

 

Im looking for some help. I have a slicer that has Year and Month. What Im trying to do is filter my data based on the month I want to do my audit. 

 

I do monthly audits based on spend from previous months. 

 

For example - I am doing audits this month (December). My audit is based on the spend from September and October.

 

What I want to be able to do is in the slicer (Audit Months) is actaully selct the month it currently is "December" and it know that I want to pull September and October data. 

 

As follows when I select january, I want it to select October and December

 

brysonb12_2-1671200833084.png

 

Any one have suggetions?

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @brysonb12 

You can create a new measure:

 

Measure 2 = var a=date(SELECTEDVALUE('Table 2'[Date].[Year]),MONTH(CONVERT(SELECTEDVALUE('Table 2'[Date].[Month]) & " 1",DATETIME) )-2,31)
var b=date(SELECTEDVALUE('Table 2'[Date].[Year]),MONTH(CONVERT(SELECTEDVALUE('Table 2'[Date].[Month]) & " 1",DATETIME) )-3,31)
var c=FILTER('Table',[sample date ]>=B&&[sample date ]<=A)
return IF(ISFILTERED('Table 2'[Date].[Month])=FALSE(),0,IF(COUNTROWS(c)>0,0,1))

 

vxinruzhumsft_0-1671433416834.png

Then put the measure to the visual filter:

vxinruzhumsft_0-1671434389477.png

 

But the condition is that the date table and the fact table cannot have a relationship:

vxinruzhumsft_1-1671433482340.png

Best Regards!

Yolo Zhu

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-xinruzhu-msft
Community Support
Community Support

Hi @brysonb12 

You can create a new measure:

 

Measure 2 = var a=date(SELECTEDVALUE('Table 2'[Date].[Year]),MONTH(CONVERT(SELECTEDVALUE('Table 2'[Date].[Month]) & " 1",DATETIME) )-2,31)
var b=date(SELECTEDVALUE('Table 2'[Date].[Year]),MONTH(CONVERT(SELECTEDVALUE('Table 2'[Date].[Month]) & " 1",DATETIME) )-3,31)
var c=FILTER('Table',[sample date ]>=B&&[sample date ]<=A)
return IF(ISFILTERED('Table 2'[Date].[Month])=FALSE(),0,IF(COUNTROWS(c)>0,0,1))

 

vxinruzhumsft_0-1671433416834.png

Then put the measure to the visual filter:

vxinruzhumsft_0-1671434389477.png

 

But the condition is that the date table and the fact table cannot have a relationship:

vxinruzhumsft_1-1671433482340.png

Best Regards!

Yolo Zhu

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

brysonb12
Frequent Visitor

Ocotber and November*****

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.

Top Solution Authors