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
bullius
Helper V
Helper V

Account Overdrawn This Month - Show ALL in matrix

Hi

 

I have a list of bank balances showing a snapshot of each account's balance on a given date.

 

E.g.

 

DateAccountBalanceOD This Month
01/08/20161£10FALSE
01/08/20162-£5FALSE
15/08/20162£15FALSE
01/09/20161£20FALSE
01/09/20162-£30TRUE
01/09/20163£40FALSE
15/09/20161-£10TRUE
15/09/20162£45FALSE
15/09/20163£30FALSE

 

I have added a calculated column to indicate whether an account has been overdrawn this month or not, using the following formula:

 

OD This Month =

    IF(
        AND(
            [Balance] < 0,
            MONTH( [Date] ) = MONTH( MAX( [Date] ) )
        ),
        TRUE(),
        FALSE()
    )

 

When put into a matrix, this looks like this (created in excel, but same in pbi):

 

Matrix.png

The problem is, I want to see the balances on the days that the account wasn't overdrawn as well - where the gaps are (just for those accounts that have been overdrawn at some point during this month).

 

The way I can think to do it is to create a formula that returns TRUE next to all balances (including positive ones) from an account that has been overdrawn at some point this month.

 

Could anyone help with creating this formula or is there another solution?

 

Thanks!

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @bullius

 

Here is an example of how it could be done, just using a measure rather than any calculated columns:

 

  1. Create a Calendar table with at least date and month columns
  2. Relate your main table (I've called it Balance) to the Calendar table
  3. Create the following measures:
    Account Balance = SUM ( Balance[Balance] )
    
    Account Balance for months where overdrawn = 
    CALCULATE (
        [Account Balance],
        FILTER (
            ADDCOLUMNS (
                SUMMARIZE ( Balance, Balance[Account], 'Calendar'[End of Month] ),
                "MinBalance", CALCULATE (
                    MIN ( Balance[Balance] ),
                    ALLEXCEPT ( 'Calendar', 'Calendar'[End of Month] )
                )
            ),
            [MinBalance] < 0
        )
    )
    or
  4. Account Balance for months where overdrawn v2 = 
    SUMX (
    VALUES ( Balance[Account] ),
    IF (
    CALCULATE (
    MIN ( Balance[Balance] ),
    ALL ( 'Calendar' ),
    VALUES ( 'Calendar'[End of Month] )
    )
    < 0,
    [Account Balance]
    )
    )

Sample pbix file here:

https://www.dropbox.com/s/ku2cuioh5blyoh9/Account%20Overdrawn.pbix?dl=1

 

I'm sure there are other ways of implementing similar logic.

 

Owen 🙂


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

4 REPLIES 4
OwenAuger
Super User
Super User

Hi @bullius

 

Here is an example of how it could be done, just using a measure rather than any calculated columns:

 

  1. Create a Calendar table with at least date and month columns
  2. Relate your main table (I've called it Balance) to the Calendar table
  3. Create the following measures:
    Account Balance = SUM ( Balance[Balance] )
    
    Account Balance for months where overdrawn = 
    CALCULATE (
        [Account Balance],
        FILTER (
            ADDCOLUMNS (
                SUMMARIZE ( Balance, Balance[Account], 'Calendar'[End of Month] ),
                "MinBalance", CALCULATE (
                    MIN ( Balance[Balance] ),
                    ALLEXCEPT ( 'Calendar', 'Calendar'[End of Month] )
                )
            ),
            [MinBalance] < 0
        )
    )
    or
  4. Account Balance for months where overdrawn v2 = 
    SUMX (
    VALUES ( Balance[Account] ),
    IF (
    CALCULATE (
    MIN ( Balance[Balance] ),
    ALL ( 'Calendar' ),
    VALUES ( 'Calendar'[End of Month] )
    )
    < 0,
    [Account Balance]
    )
    )

Sample pbix file here:

https://www.dropbox.com/s/ku2cuioh5blyoh9/Account%20Overdrawn.pbix?dl=1

 

I'm sure there are other ways of implementing similar logic.

 

Owen 🙂


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Thanks @OwenAuger

 

This logic works! I hadn't thought of approaching it like that.

v-yuezhe-msft
Employee
Employee

Hi @bullius,

I am not sure what specific values you want to show in your matrix visual, could you please describe more details?

If you want display Matrix visual as follows, you don’t need to use OD This Month slicer, just choose 1 and 2 using visual filter to filter your matrix.
1.PNG


Thanks,
Lydia Zhang

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks @v-yuezhe-msft

 

The above data is just an example. Your solution would work for this data, but the solution for the actual data needs to be more dynamic.

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.