cancel
Showing results for 
Search instead for 
Did you mean: 
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
Vote for T-Shirt Design

Power BI T-Shirt Design Challenge 2023

Vote for your favorite t-shirt design now through March 28.

March 2023 Update3

Power BI March 2023 Update

Find out more about the March 2023 update.

March Events 2023A

March 2023 Events

Find out more about the online and in person events happening in March!