Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
lynnsop
Helper I
Helper I

Return depending on number of selected column from slicer

Hi People.

 

I need a measure doing the following depending on what I select on a slicer:

 

When I select multiple values: Return "Multiple"
When I select no value: Return "No"

When I select a single value (1): Return Last Date

 

Column which gets filtered in slicer:

2021-01

2021-02

2021-03

 

I have created the following measure for this:

Measure23 =

Switch(true() ,
not(isfiltered('KPIs Summary'[Actual Date])) , "",
countx(allselected('KPIs Summary'[Actual Date]), 'KPIs Summary'[Actual Date]) >1 ,"From Selected Dates", LASTDATE('KPIs Summary'[Actual Date]))
 
This seems to work except for the marked part. It gives me the following result instead of 2021-03:lynnsop_0-1625747768901.png

Do you have an solution or new measure for this?

 
1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @lynnsop ,

 

I checked your formula, there is no problem in import mode. It should be noted that the [Actual Date] column needs to be in date format.

If your data source connection mode is direct query, it may cause this problem. It is recommended that you rewrite measure as:

Switch(true() ,
not(isfiltered('KPIs Summary'[Actual Date])) , "",
countx(allselected('KPIs Summary'[Actual Date]), 'KPIs Summary'[Actual Date]) >1 ,"From Selected Dates", SELECTEDVALUE('KPIs Summary'[Actual Date]))

 

 

Best Regards,
Liang
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

7 REPLIES 7
V-lianl-msft
Community Support
Community Support

Hi @lynnsop ,

 

Is this problem has been solved?

If the problem persists, please share a sample pbix with dummy data.

 

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

Hi @V-lianl-msft 

 

I found a workaround for that so I dont have to use that "complex" DAX. Thanks for your help and time! 🙂

V-lianl-msft
Community Support
Community Support

Hi @lynnsop ,

 

I checked your formula, there is no problem in import mode. It should be noted that the [Actual Date] column needs to be in date format.

If your data source connection mode is direct query, it may cause this problem. It is recommended that you rewrite measure as:

Switch(true() ,
not(isfiltered('KPIs Summary'[Actual Date])) , "",
countx(allselected('KPIs Summary'[Actual Date]), 'KPIs Summary'[Actual Date]) >1 ,"From Selected Dates", SELECTEDVALUE('KPIs Summary'[Actual Date]))

 

 

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

amitchandak
Super User
Super User

@lynnsop , Try if that can help

 

countx(allselected('KPIs Summary'[Actual Date]),filter( 'KPIs Summary', 'KPIs Summary'[Actual Date] >1 && 'KPIs Summary'[Actual Date] = LASTDATE('KPIs Summary'[Actual Date])))

 

or

 

meausre =

var _max = maxx(allselected('KPIs Summary', 'KPIs Summary'[Actual Date])
return
countx(allselected('KPIs Summary'[Actual Date]),filter( 'KPIs Summary', 'KPIs Summary'[Actual Date] >1 && 'KPIs Summary'[Actual Date] = LASTDATE('KPIs Summary'[Actual Date])))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hey @amitchandak thanks for your answer. 

Unfortunately both measure do not seem to work.

1st:

lynnsop_1-1625750461982.png

 



2nd:

lynnsop_0-1625750378942.png

 

@lynnsop , Sorry, My mistake.

 

Try if these can work

 

countx(filter(allselected('KPIs Summary'[Actual Date]), 'KPIs Summary'[Actual Date] >1 && 'KPIs Summary'[Actual Date] = LASTDATE('KPIs Summary'[Actual Date])),
'KPIs Summary'[Actual Date])

 

measure =

var _max = maxx(allselected('KPIs Summary', 'KPIs Summary'[Actual Date])
return
countx(allselected('KPIs Summary'[Actual Date]),filter( 'KPIs Summary', 'KPIs Summary'[Actual Date] >1 && 'KPIs Summary'[Actual Date] = LASTDATE('KPIs Summary'[Actual Date]))
, 'KPIs Summary'[Actual Date])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak 
Still not working 😞

1st is just showing me the amount of filters I selected regardless of if i combine it with my switch:

lynnsop_1-1625751413964.png

 

2nd:

lynnsop_0-1625751339774.png

Even when I fix the ) in MAXX Function

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors