Forum Discussion

Maithilitiwari's avatar
Maithilitiwari
Frequent Visitor
2 years ago
Solved

IF Statement

Recurring Bookings = IF( ISFILTERED(Renewal[RENEW FLAG]) &&

SELECTEDVALUE(Renewal[RENEW FLAG]) = "NEW BUSINESS" &&

SELECTEDVALUE(BusinessMix[Bookings by Class]) IN {"License Support", "Hardware Support", "Subscription", "SAAS", "BCS", "Consumption"},

"True",

"False" )

This measure should return True when the following conditions are met: Renewal[RENEW FLAG] is filtered. The selected value of Renewal[RENEW FLAG] is "NEW BUSINESS". The selected value of BusinessMix[Bookings by Class] is all of the specified classes only if anything else is selected or no value is selected then it should return false

  • Recurring Bookings =
    IF(
        ISFILTERED(Renewal[RENEW FLAG]) &&
        SELECTEDVALUE(Renewal[RENEW FLAG]) = "NEW BUSINESS" &&
        COUNTROWS(
            FILTER(
                ALLSELECTED(BusinessMix[BookinLicense Support", "Hardware Support", "Subscription", "SAAS", "BCS", "Consumption"}gs by Class]),
                BusinessMix[Bookings by Class] IN {"
            )
        ) = 6 &&
        COUNTROWS(ALLSELECTED(BusinessMix[Bookings by Class])) = 6,
        "True",
        "False"
    )
     
     
    This code is working
    So if i select all of these
    ("License Support", "Hardware Support", "Subscription", "SAAS", "BCS", "Consumption") i get true and if anything is missing or nothing is selected it gives me false

6 Replies

    • Maithilitiwari's avatar
      Maithilitiwari
      Frequent Visitor

      I am getting true only when License Support is selected apart from that i am getting false

       

    • Maithilitiwari's avatar
      Maithilitiwari
      Frequent Visitor

      I am getting true only when License Support is selected apart from that i am getting false there is a logical error

       

      • manvishah17's avatar
        manvishah17
        Solution Supplier

        If you are getting "True" only when "License Support" is selected and "False" otherwise,  the issue might be with how the values are being compared or how the SELECTEDVALUE function is operating within the filter context.
        Could you please share sample dataset..
        or else try this dax 

         

        Recurring Bookings = 
        VAR SelectedRenewFlag = SELECTEDVALUE(Renewal[RENEW FLAG])
        VAR SelectedBookingClass = SELECTEDVALUE(BusinessMix[Bookings by Class])
        VAR ValidClasses = {"License Support", "Hardware Support", "Subscription", "SAAS", "BCS", "Consumption"}
        
        RETURN
        IF(
            ISFILTERED(Renewal[RENEW FLAG]) &&
            SelectedRenewFlag = "NEW BUSINESS" &&
            NOT ISBLANK(SelectedBookingClass) &&
            SelectedBookingClass IN ValidClasses,
            "True",
            "False"
        )

         

        If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
        If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!