Forum Discussion
SELECTEDVALUE function not working in bar graph
This dax gives below bar graph
But when same measure used in selected value function, without using any slicer, it is not showing data for may month
Both graphs should show same data if no slicer is selected, what am I missing
Pls help as it is for live project
Hi rohank11
Thanks for raising this Fabric Community
Your ALL-status bars went missing because SELECTEDVALUE returned a single status (“Declined” or “Dropped”) in May’s context, and your SWITCH sent those to zero. To show the full running-total when nothing (or multiple statuses) is selected, use one of these patterns:
Total Active Patients =
IF(
HASONEVALUE( Append1[PatientStatus] ),
SWITCH(
VALUES( Append1[PatientStatus] ),
"Declined", 0,
"Dropped", 0,
[Total Active Patients in current month]
),
[Total Active Patients in current month]
)
For more details, see the official docs:
• SELECTEDVALUE → https://learn.microsoft.com/dax/selectedvalue-function-dax
• HASONEVALUE → https://learn.microsoft.com/dax/hasonevalue-function-dax
• SWITCH → https://learn.microsoft.com/dax/switch-function-dax
If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth.
6 Replies
- johnt75Super User
My guess would be that in May's data there is only 1 status, either Declined or Dropped, so SELECTEDVALUE returns that and matches one of the clauses in the SWITCH.
- PijushRoyCommunity Champion
Hi rohank11
Can you please try below codeSWITCH( TRUE(),IF(ISFilter(Append1[PatientStatus])) && SELECTEDVALUE(Append1[PatientStatus])="Declined",0, IF(ISFilter(Append1[PatientStatus])) && SELECTEDVALUE(Append1[PatientStatus])="Dropped",0, [Total Active Patients in current month] ) - v-csrikanthCommunity Support
Hi rohank11
Thanks for raising this Fabric Community
Your ALL-status bars went missing because SELECTEDVALUE returned a single status (“Declined” or “Dropped”) in May’s context, and your SWITCH sent those to zero. To show the full running-total when nothing (or multiple statuses) is selected, use one of these patterns:
Total Active Patients =
IF(
HASONEVALUE( Append1[PatientStatus] ),
SWITCH(
VALUES( Append1[PatientStatus] ),
"Declined", 0,
"Dropped", 0,
[Total Active Patients in current month]
),
[Total Active Patients in current month]
)
For more details, see the official docs:
• SELECTEDVALUE → https://learn.microsoft.com/dax/selectedvalue-function-dax
• HASONEVALUE → https://learn.microsoft.com/dax/hasonevalue-function-dax
• SWITCH → https://learn.microsoft.com/dax/switch-function-dax
If the above information is helpful, please give us Kudos and mark the response as Accepted as solution.
Best Regards,
Community Support Team _ C Srikanth. - v-csrikanthCommunity Support
Hi rohank11
I wanted to follow up since I haven't heard from you in a while. Have you had a chance to try the suggested solutions?
If your issue is resolved, please consider marking the post as solved. However, if you're still facing challenges, feel free to share the details, and we'll be happy to assist you further.
Looking forward to your response!
Best Regards,
Community Support Team _ C Srikanth. - v-csrikanthCommunity Support
Hi rohank11
It's been a while since I heard back from you and I wanted to follow up. Have you had a chance to try the solutions that have been offered?
If the issue has been resolved, can you mark the post as resolved? If you're still experiencing challenges, please feel free to let us know and we'll be happy to continue to help!
Looking forward to your reply!Best Regards,
Community Support Team _ C Srikanth. - v-csrikanthCommunity Support
Hi rohank11
It's been a while since I heard back from you and I wanted to follow up. Have you had a chance to try the solutions that have been offered?
If the issue has been resolved, can you mark the post as resolved? If you're still experiencing challenges, please feel free to let us know and we'll be happy to continue to help!
Looking forward to your reply!Best Regards,
Community Support Team _ C Srikanth.