Forum Discussion

rohank11's avatar
rohank11
Frequent Visitor
1 year ago
Solved

SELECTEDVALUE function not working in bar graph

This dax gives below bar graph Total Active Patients in current month =         VAR TOTALVALUE =   (                 [New Patients running total in Date] - [Drop off Patients running total in Dat...
  • v-csrikanth's avatar
    1 year ago

    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.