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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
pfernandez
New Member

Hasonevalue not working

I have a field name called Dr_Cr_Balance, which only has one value in the Chart of Accounts table. In the following expression I am testing to see if Hasonevalue = "debit" or "credit". If "debit, I want to multiple the TOTALYTD by 1, and if the value in the Chart of Accounts is "credit" then multiply it by -1.  The expression works as long as there is a number in the MTD Actual column. If this is blank, then the YTD Actual has the wrong sign. Anyone have any ideas on how to fix this?

pfernandez_1-1675816095589.png

 

 

 

5 REPLIES 5
pfernandez
New Member

Can anyone help with the formula and the error message in my last message?

amitchandak
Super User
Super User

@pfernandez , It is better to have a measure like

 

Calculate(

calculate(1* [Amount $], filter(ChartofAccount, ChartofAccount[Dr_cr_flag]= "Dr")  +

calculate(-1* [Amount $], filter(ChartofAccount, ChartofAccount[Dr_cr_flag]= "Cr"),  Dateytd(Date[Date]) ) 

 

I do not think you all date , make sure date table is marked as date table and used in visual if needed

 

 

Why Time Intelligence Fails - Powerbi 5 Savior Steps for TI :https://youtu.be/OBf0rjpp5Hw
https://amitchandak.medium.com/power-bi-5-key-points-to-make-time-intelligence-successful-bd52912a5b...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi Amitchandak, I tried this and I probably have a mistake somewhere in the formula. Can you take a look and help me fix this?

pfernandez_0-1675822710171.png

 

It looks like i was missing a comma in the second CALCULATE function. I added the comma and now I have this:

YTD Actual = CALCULATE(1 * [Amount $], FILTER(Chart_of_Accounts, Chart_of_Accounts[Dr_Cr_Balance] - "debit") + CALCULATE (-1 * [Amount $], FILTER(Chart_of_Accounts, Chart_of_Accounts[Dr_Cr_Balance] = "credit", DATESYTD('Date'[Date], "12/31"), ALL('Date'))))
I am not getting a message saying "too many arguments were passed to the FILTER function. The maximum argument count for the function is 2."

I am still looking for a solution. Does anyone know how to fix the above DAX statement?

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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