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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Anonymous
Not applicable

## Help with DAX to find Zero Balance Accounts

Hi All,

Can someone please help me to write DAX to calculate the total distict count of Zero Balance Accounts based on below mentioned logic :-

Logic Defintion : For a particular Account Number , the YTD Balance should be equal to = 0 in all the years i.e 2018,2019,2020 (not any of the two or one specific year). YTD Balance should be 0 for 2018 AND 2019 AND 2020.  If for a account this is true then it would be counted as one.

Logic should be something like this Considering Account number : 10154

Condition 1 --> Account 10154 : YTD Balance = 0 AND Year=2018

Condition 2 -->Account 10154 : YTD Balance = 0 AND Year=2019

Condition 3 -->Account 10154 : YTD Balance = 0 AND Year=2020

If all three conditions are true then count should be taken as one. Similarly this DAX Measure should COUNT all other Accounts where this above condition is met. Example shown below :-

Example Account

NOTE : One account can have transactions under multiple companies as well . This needs to be considered while designing the desired DAX . In above screenshot Account : 10154  is having transaction under only one Company . But there are chances that one account is having transaction under multiple Companies such as 8000, etc.

So this is required to be calculated for all the Accounts in the Dataset attached as mentioned below :-

Actual Dataset

Thanks & Regards,

Ashish Sharma

1 ACCEPTED SOLUTION
Community Support

Hi @Anonymous ,

We can create a measure and add a card visual to meet your requirement.

``````distict count of Accounts =
CALCULATE (
DISTINCTCOUNT ( 'Table'[account] ),
FILTER (
SUMMARIZE (
FILTER (
'Table',
'Table'[year] = 2018
|| 'Table'[year] = 2019
|| 'Table'[year] = 2020
),
'Table'[account],
"YTD_total", CALCULATE ( SUM ( 'Table'[YTD] ) )
),
[YTD_total] = 0
)
)``````

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.

Best regards,

Community Support Team _ zhenbw

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

2 REPLIES 2
Super User

@Anonymous

Please see if the below solution can help you.

1. create a column.

2. Use below DAX coding

``testing = iF(SUMX(FILTER('table','table'[account]=EARLIER('table'[account])),'table'[YTD balance])=0,'table'[account],'table'[account]&'table'[year])``

Thanks and BR

Ryan

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Community Support

Hi @Anonymous ,

We can create a measure and add a card visual to meet your requirement.

``````distict count of Accounts =
CALCULATE (
DISTINCTCOUNT ( 'Table'[account] ),
FILTER (
SUMMARIZE (
FILTER (
'Table',
'Table'[year] = 2018
|| 'Table'[year] = 2019
|| 'Table'[year] = 2020
),
'Table'[account],
"YTD_total", CALCULATE ( SUM ( 'Table'[YTD] ) )
),
[YTD_total] = 0
)
)``````

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that you have shared?

BTW, pbix as attached.

Best regards,

Community Support Team _ zhenbw

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

## Helpful resources

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Join our Community Sticker Challenge

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

#### Power BI Monthly Update - July 2024

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

#### Fabric Community Update - July 2024

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

Top Solution Authors
Top Kudoed Authors