IF statment (DAX) in powerpivot

ehardway123

New Member
Joined
May 24, 2013
Messages
22
Hello,
I am having a had time having this function work properly. I am creating a proper P and L sheet using powerpivot. Meaning I want both my expenses and revenue as positive value on the sheet. Right now the revenue show up as negative and expenses as positive. So I need to make the Revenue Positive and also keep the expenses positive also. This website showed me how by using HASONEVALUE using an DAX IF statement but its not working properly. I get the error message, The syntax ',' is incorrect. What I have is Account type which is Revenue and expenses, and then I have account group which is subcatgories under those and account names which is services/products under the account group and also division amount, which is the dollar amount of each revenue/expense. the following is the formula I used:

=([DIVISION AMT])*-1)*IF(HASONEVALUE([ACCOUNT TYPE])), IF(VALUES([ACCOUNT TYPE])= "EXPENSES" ,-1, 1), 1)
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Hi ehardway,

A quick question, why not use the ABS command? The ABS command converts negative values to positive.

I added a calculation of =ABS([Division Amt]), and then a column calculation of Sum of ABS Value:=SUM([ABS Value])

Kim.
 
Upvote 0
Kim,

That would not work. In a proper Profit/Loss sheet, the revenue would be debit and be positive and expenses are credit and be positive too, but sometimes a expense it is a debit which would show as negative on the sheet since because it is not credit like the rest of the expenses. That cannot be shown as an absolute value. Thanks for your help anyways.
 
Upvote 0
Hi ehardway,

Apologies, I should have realized. I simplified the function to the one below.

Code:
=([Division Amt]*-1) * IF([Account Type]="EXPENSES", -1, 1)


I'm not quite sure what the aim of using HASONEVALUE([ACCOUNT TYPE]))?


Kim
 
Upvote 0
Hi ehardway,

Apologies, I should have realized. I simplified the function to the one below.

Code:
=([Division Amt]*-1) * IF([Account Type]="EXPENSES", -1, 1)


I'm not quite sure what the aim of using HASONEVALUE([ACCOUNT TYPE]))?


Kim

Hi ehardway,

I also did some quick reading of HASONEVALUE vs. ISFILTERED vs. HASONEFILTER « PowerPivotPro and then made some slight adjustments to your function. I did the following:

  1. Removed the extra ) from ([DIVISION AMT])*-1)
  2. Change HASONEVALUE to HASONEFILTER
  3. Changed VALUES([ACCOUNT TYPE]) to [ACCOUNT TYPE]

Code:
=([DIVISION AMT]*-1)* IF(HASONEFILTER([ACCOUNT TYPE]), IF([Account Type]="EXPENSES", -1, 1), 1)

Kim.
 
Upvote 0
Kim,

Both the codes did not work. On the one where you simplified, it still had the expenses be negative. The second one with HASONEFILTER made the revenue become negative. I want all to be shown positive,unless it is a credit in the revenue and debit in expenses. Thanks for the help of it tho. Do you have an idea what else to do?
 
Upvote 0
I like Tianbas's answer, you just need to replace his generic "Table" with the actual name of YOUR Table (which we dont know...)
 
Upvote 0

Forum statistics

Threads
1,223,229
Messages
6,170,881
Members
452,364
Latest member
springate

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top