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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
sinanalmac
Resolver I
Resolver I

SELECTED VALUE IS true When I select Two or three months

 Hi ALL,
I wrote a calculation about a  slicer with a selected value function. Return false if  something is selected , return True  is something unselected.

her is my  calculation 

MTD TO = 
var MonthTest = SELECTEDVALUE(DistributorTarget[Month])

var  calc =IF(ISBLANK(Monthtest)=FALSE(),  CALCULATE(SUM(DistributorTarget[ActualValue])),
                           CALCULATE(SUM(DistributorTarget[ActualValue]),FILTER('Date','Date'[ThisMonthMTD] = 1),FILTER(DistributorTarget,Convert(DistributorTarget[Year],INTEGER)=YEAR(TODAY()))))

return calc

here is my true/false test example 

A_Test_False/True = 

var MonthTest = SELECTEDVALUE(DistributorTarget[Month])


var calc = IF(ISBLANK(MonthTest)=FALSE(),"false",

"true")

return calc




when  I selected One month or selected all,  it works.  But when I selected more  than one month it return true and it is like behavior for all months selected. I just want to calculate it  selected month's amount

How can I solve this issue? 

sinanalmac_0-1658385932623.pngsinanalmac_1-1658385984913.png

 

sinanalmac_2-1658386041483.png

 

Best regards
Sinan 



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

Hi @sinanalmac ,

 

Please be aware of that selectedvalue() function will return blank if there are multiple values selected.

In this case you could use COUNTROWS(VALUES(<columnName>)) = 1 or HASONEVALUE() function instead.

 

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.

View solution in original post

3 REPLIES 3
v-jayw-msft
Community Support
Community Support

Hi @sinanalmac ,

 

Please be aware of that selectedvalue() function will return blank if there are multiple values selected.

In this case you could use COUNTROWS(VALUES(<columnName>)) = 1 or HASONEVALUE() function instead.

 

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.
lukiz84
Memorable Member
Memorable Member

what amitchandak said, but just to add a little info:

 

selectedvalue ONLY returns a value when there is ONLY ONE selected... thats why the results are correct!

amitchandak
Super User
Super User

@sinanalmac , You can use hasonevalue and isfiltered - https://powerpivotpro.com/2013/03/hasonevalue-vs-isfiltered-vs-hasonefilter/

 

Or you can check

countrows(allselected(Table[Month] )) >1 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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