Forum Discussion

Brookied's avatar
Brookied
Helper I
5 years ago
Solved

DAX help needed

Afternoon All, 

I need a little help to get the below working as expected. 

 

 I have a table of income data,  this would inclusde

Amount = Various values

Payment Date = date of payment 

SourceCode  = Structured source code to track payments

Payment Method = Cash,  Direct Debit etc..

 

I have a custom column" that for the most par works, Everything below execpt the section in bold works.   What i want to happen is 

this exceprt from SQL

 

"case

when sourcecode like 'A%' and sourcecode not in ('AUGO','AUPO','AURO','AUTO','AUCO','AUFO','OOOO','OAMA','OANA',

    'OARS','ZREF','ZBAN','NAUG','AWAO','BUSR') and sourcecode not like 'AV%' then '01_Cash'

"

 

I constructed the par in bold and while no errors i dont seem to see in my SourceType Column the CASH value returned?

 

IF anyone has any pointers please fire th

 

SOURECTYPE =
IF(
'Fundraising Inc Report'[SOURCE_LETTER] = "A" && 'Fundraising Inc Report'[Payment Method]="TAX",
"TAX",IF(
'Fundraising Inc Report'[SOURCE_LETTER] = "A" && 'Fundraising Inc Report'[Payment Method]<>"TAX",
"Appeals",IF(
'Fundraising Inc Report'[SOURCE_LETTER] = "C",
"Corporate",IF(
'Fundraising Inc Report'[SOURCE_LETTER] = "E",
"Emergencies",IF(
'Fundraising Inc Report'[SOURCE_LETTER] = "L",
"Legacy",IF(
'Fundraising Inc Report'[SOURCE_LETTER] = "M",
"Major Donor",IF(
'Fundraising Inc Report'[SOURCE_LETTER] = "R",
"Community",IF(
'Fundraising Inc Report'[SOURCE_LETTER] = "U",
"Unattributable",IF(
'Fundraising Inc Report'[SOURCE_LETTER] = "Z",
"Refunds/Fees", IF(
'Fundraising Inc Report'[SOURCE_LETTER] = "A" && NOT
(SEARCH("AUGO", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("AUPO", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("AURO", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("AUTO", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("AUCO", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("AUFO", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("OOOO", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("OAMA", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("OANA", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("OARS", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("ZREF", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("ZBAN", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("NAUG", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("AWAO", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("BUSR", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("AUGO", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0 ||
SEARCH("AV**", 'Fundraising Inc Report'[Source Code (Source Campaign)] ,, 0 ) <> 0), "Cash",
 
IF('Fundraising Inc Report'[SOURCE_LETTER] = "0",
"000 Various", "MISC"
)
))))))))))

 

  • Brookied 

    have you tried

    IF(LEFT(SOUCECODE,1)="A" && NOT SOURCECODE IN {"XXX","XXX","XXX"}&&LEFT(SOURCECODE,2)<>"AV", "01_CASH")

2 Replies

  • Brookied 

    have you tried

    IF(LEFT(SOUCECODE,1)="A" && NOT SOURCECODE IN {"XXX","XXX","XXX"}&&LEFT(SOURCECODE,2)<>"AV", "01_CASH")

    • Brookied's avatar
      Brookied
      Helper I

      ryan_mayu 

      I have not so let me rebuild based on above syntax and will let you know,   Thanks