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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
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 AccountExample 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 DatasetActual Dataset

Thanks & Regards,

Ashish Sharma  

1 ACCEPTED SOLUTION
v-zhenbw-msft
Community Support
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
    )
)

 

Help 1.jpg

 

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.

View solution in original post

2 REPLIES 2
ryan_mayu
Super User
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])

 

Capture.PNG

 

Thanks and BR

Ryan





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

Proud to be a Super User!




v-zhenbw-msft
Community Support
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
    )
)

 

Help 1.jpg

 

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors