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
amirabedhiafi
Impactful Individual
Impactful Individual

Create a filter with condition in selection with an alert

 

I have a filter containing the Year and the Month like below :

 

bsX6v.png

I want to make a rule to select only one year and two months in that year. Example : I select 2020 and then April and May.

Can I also add a message alert ? when selecting only one year and one month, a message appears "You should select two months"

Amira Bedhiafi
Full Stack Business Intelligence Consultant @Capgemini
1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @amirabedhiafi 

Thanks for reaching out to us.

You can try this,

1. insert a text box, and create the measure, 

Measure = 
    var _selectedYears=IF(ISFILTERED('Table'[Date].[Year]),CALCULATE(DISTINCTCOUNT('Table'[Date].[Year]),ALLSELECTED('Table')))
    var _selectedMonths=IF(ISFILTERED('Table'[Date].[Year]),CALCULATE(DISTINCTCOUNT('Table'[Date].[Month]),ALLSELECTED('Table')))  
return IF(_selectedYears<>1||_selectedMonths<>2,"You should select two months")

2. then put the measure into the text box

vxiaotang_0-1635218890810.png

result

vxiaotang_3-1635219223896.gif

 

 

Best Regards,

Community Support Team _Tang

If this post helps, 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-xiaotang
Community Support
Community Support

Hi @amirabedhiafi 

Thanks for reaching out to us.

You can try this,

1. insert a text box, and create the measure, 

Measure = 
    var _selectedYears=IF(ISFILTERED('Table'[Date].[Year]),CALCULATE(DISTINCTCOUNT('Table'[Date].[Year]),ALLSELECTED('Table')))
    var _selectedMonths=IF(ISFILTERED('Table'[Date].[Year]),CALCULATE(DISTINCTCOUNT('Table'[Date].[Month]),ALLSELECTED('Table')))  
return IF(_selectedYears<>1||_selectedMonths<>2,"You should select two months")

2. then put the measure into the text box

vxiaotang_0-1635218890810.png

result

vxiaotang_3-1635219223896.gif

 

 

Best Regards,

Community Support Team _Tang

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

VahidDM
Super User
Super User

Hi @amirabedhiafi 

 

Create a measure with the below codes and add that to the Text Box:

 

Text Alert =
VAR _DC =
    DISTINCTCOUNT ( [Month] )
RETURN
    IF ( _DC <> 2, "You should select two months", BLANK () )

 

 

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

 

Appreciate your Kudos!!

 

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.