Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

need Urgent help

Hi Team,

I have sql query with Where condition,but in Where condition I have 3-4 case condition with AND,OR.These case condition will get the parameters from slicer selection.Can any one please help on this how can i have to achieve this one.

For Reference I  have attaching one sample query

N'CIBC_TO_CIBC' :Slicer selection value(it will change according to selection)

 

and a13.TRANSFERBATCHID in ('BT20160103059867')
and a17.MaxPrimSecId in (N'00#990070')
and
(
(
N'CIBC_TO_CIBC' = 'CIBC_TO_CIBC'
AND a13.FromCustodialBank IN ('CIBC Mellon')
AND a13.ToCustodialBank IN ('CIBC Mellon')
)
OR
(
N'CIBC_TO_CIBC' = 'BNY_TO_BNY'
AND a13.FromCustodialBank IN ('BNY Mellon')
AND a13.ToCustodialBank IN ('BNY Mellon')
)
OR
(
N'CIBC_TO_CIBC' = 'BNY_TO_CIBC'
AND a13.FromCustodialBank IN ('BNY Mellon')
AND a13.ToCustodialBank IN ('CIBC Mellon')
)
OR
(
N'CIBC_TO_CIBC' = 'CIBC_TO_BNY'
AND a13.FromCustodialBank IN ('CIBC Mellon')
AND a13.ToCustodialBank IN ('BNY Mellon')
)
OR
(
N'CIBC_TO_CIBC' = 'EXCEPTIONAL'
AND
(
(( a15.IsRegionUSCanada ) is null OR ( a15.IsRegionUSCanada )='')
OR
(( a18.IsRegionUSCanada ) IS NULL OR ( a18.IsRegionUSCanada )='')
)
)
OR
(
N'CIBC_TO_CIBC' = 'NON_USD_CAD_ACCOUNTS'
AND
(
a15.IsRegionUSCanada IN ('N')
)
AND
(
a13.Currency NOT IN ('USD','CAD')
)
AND
(
(a13.FromCustodialBank NOT IN ('CIBC Mellon','BNY Mellon'))
OR
(a13.ToCustodialBank NOT IN ('CIBC Mellon','BNY Mellon'))
)
)
OR
(
N'CIBC_TO_CIBC' = 'OTHER_USD_CAD_ACCOUNTS'
AND
(
a15.IsRegionUSCanada IN ('Y')
)
AND
(
a18.IsRegionUSCanada IN ('Y')
)
AND
(
a13.Currency IN ('USD','CAD')
)
AND
(
(a13.FromCustodialBank NOT IN ('CIBC Mellon','BNY Mellon'))
OR
(a13.ToCustodialBank NOT IN ('CIBC Mellon','BNY Mellon'))
)
)
OR
(
N'CIBC_TO_CIBC' = 'NONE'
)

)
and
(
(
'OFFICIAL' ='OFFICIAL'
AND ( a13.TransferStatus ) IN (10,11,25)
)
OR
'OFFICIAL'='ALL'
)

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Please help on this

    • Pragati11's avatar
      Pragati11
      Icon for Super User rankSuper User

      Hi Anonymous ,

       

      Did you read my previous response on to provide more details?

       

       

    • Greg_Deckler's avatar
      Greg_Deckler
      Icon for Community Champion rankCommunity Champion

      Anonymous - Please refer to Pragati11 's guidance on this, simply posting SQL code is not a path towards a solution. Sample data, expected output, describe what you are trying to achieve. Proven to speed a resolution.

  • v-lionel-msft's avatar
    v-lionel-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    Do you want to refer to the slicer value in the SQL where condition?

    This seems impossible.

    I suggest you use DAX to model data in Power BI Desktop.

    You can describe what data model you want to build. Or what do you want to achieve in the end?

    Or submit your idea 

     

    Best regards,
    Lionel Chen

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