Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
blazer12219
Frequent Visitor

DAX IF Statement formula in added Column

Accounting SQL database accessing does recognize Credit Memos as negatives so when add total Taxable Sales the total is wrong.

 

Attempting to add new Column to Database that looks at TrxType 2 which is a credit memo than multiples that total by -1.0 to turn it to a negative that if anything else it just returns the TaxableAmt for that row so when added all together the total is correct.

 

When attempting formula just will not calculate properly

 

IF [TrxType] = 2 then ([TaxableAmt]*-1) else ([TaxableAmt])) also tried

IF([TrxType]=2,([TaxableAmt]*-1),([TaxableAmt]))

 

any help appreciated,

1 REPLY 1
edhans
Super User
Super User

You are better off doing this in Power Query. I suspect your TrxType isn't an integer is why DAX is failing, but you can clearly see the data type in Power Query. Assuming it is an integer, you'd use this:

 

 

if [TrxType] = 2 then -[TaxableAmt] else [TaxableAmt]

 

 

If it is a string, then use this

 

 

if [TrxType] = "2" then -[TaxableAmt] else [TaxableAmt]

 

 

Then get rid of the original TaxableAmt column, and rename the new custom column TaxableAmt, make sure it is typed as a number, integer, or currency (number with 4 decimal places) to suit your needs, then close and load.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors