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
rschaudhr
Resolver II
Resolver II

Default value when no filter selected

I have a case where I have the following data:

 

rschaudhr_0-1620942553404.png

There is a slicer based on the department. When Finance is selected in the slicer, another visual will display the comments related to finance. However, when no value is selected in the department slicer, the comments visual should show comments from Investment department.

 

Thank you,

 

Rehan 

2 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

Hi @rschaudhr,

 

You should use a measure similar to the one below:

 

Comments selection =
IF (
    ISFILTERED ( CommentsTable[Department] ),
    SELECTEDVALUE ( CommentsTable[Comments] ),
    CALCULATE (
        SELECTEDVALUE ( CommentsTable[Comments] ),
        FILTER (
            ALL ( CommentsTable[Department], CommentsTable[Comments] ),
            CommentsTable[Department] = "Investments"
        )
    )
)

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Hi @MFelix ,

 

Thank you! It works very well. I should have mentioned earlier. This dax code very works well when you just select one department or there is no selection. It does not work when you select multiple selection. Is there a way to do that?

 

Thank you again for your help.

 

 

View solution in original post

7 REPLIES 7
v-jayw-msft
Community Support
Community Support

Hi @rschaudhr ,

 

You will need to create a independed department table and use it as slicer.

slicer = DISTINCT('Table'[DEP])

Then create a measure as below and add it to visual filter.

Measure = IF(ISFILTERED(slicer[DEP]),IF(SELECTEDVALUE('Table'[DEP]) in VALUES(slicer[DEP]),1,0),IF(SELECTEDVALUE('Table'[DEP])="INV",1,0))

2.PNG

3.PNG

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

@v-jayw-msft , Thank you! This work very well. 

MFelix
Super User
Super User

Hi @rschaudhr,

 

You should use a measure similar to the one below:

 

Comments selection =
IF (
    ISFILTERED ( CommentsTable[Department] ),
    SELECTEDVALUE ( CommentsTable[Comments] ),
    CALCULATE (
        SELECTEDVALUE ( CommentsTable[Comments] ),
        FILTER (
            ALL ( CommentsTable[Department], CommentsTable[Comments] ),
            CommentsTable[Department] = "Investments"
        )
    )
)

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix ,

 

Thank you! It works very well. I should have mentioned earlier. This dax code very works well when you just select one department or there is no selection. It does not work when you select multiple selection. Is there a way to do that?

 

Thank you again for your help.

 

 

Hi @rschaudhr ,

 

What do you want when more than one is selected on the slicer? All of the values or just the first one?

 

If you want to concatenate all the values then you should use somethig similar to this one:

 

Comments selection = 
IF (
    ISFILTERED ( CommentsTable[Department] ),
    CONCATENATEX(ALLSELECTED(CommentsTable[Comments],CommentsTable[Department]), CommentsTable[Comments], "/"),
    CALCULATE (
        SELECTEDVALUE ( CommentsTable[Comments] ),
        FILTER (
            ALL ( CommentsTable[Department], CommentsTable[Comments] ),
            CommentsTable[Department] = "Investments"
        )
    )
)

 

Be aware that this gives you a text value with all the comments selected also if you have all the values selected on your slicer what works is the last syntax does not return only the Investment.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix ,

 

So below are a few senario:

 

1) when no filter is selected in department slicer, only investment comment will show.

2) when HR filter is selected in department slicer, only HR comment will show.

3) when HR and IT filter is selected in department slicer, then HR and IT comments will show.

4) when HR, IT and Operation filter is selected in department slicer, then HR, IT and operation comments will show. 

5) when All filter is selected in department slicer, then all comment will show.

 

I hope these senarios help.

 

Thank you!

Correct for all of them.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.