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
Anonymous
Not applicable

How to handle nulls without the extra 0's

Hello,

 

I have the following data set

 

BranchBudget CategoryCAD Amount
EdmontonLoan8331
EdmontonDeposit8991
CalgaryLoan8940
VancouverLoan6208
Yellow KnifeLoan9703
LondonLoan8186
VictoriaLoan4453
TorontoDeposit2271

 

Expected output

 

A

BranchTotal Deposits
Edmonton8991
Toronto2271
 
B
BranchTotal DepositsTotal Loans
Edmonton89918331
Calgary08940
Vancouver06208
Yellow Knife09703
London08186
Victoria04453
Toronto22710
 
 
I can get the output A with the following code
Total Deposits= CALCULATE(SUM(Sheet1[Value]), FILTER(Sheet1,Sheet1[Budget Category]="Deposit") )
 
but this does not help me achieve the output b, it returns blanks because the values dont exist.
Edmonton89918331
Calgary 8940
Vancouver 6208
Yellow Knife 9703
London 8186
Victoria 4453
Toronto2271 
 
but when I try to handle nulls using the below code I get extra 0's as shown below if I only show Total Deposits. I want the output A & B.
Total Deposits =
VAR tot = CALCULATE(SUM(Sheet1[Value]), FILTER(Sheet1,Sheet1[Budget Category]="Deposit") )
RETURN IF(ISBLANK(tot),0,tot)
 
 
BranchTotal Deposits
Edmonton8991
Calgary0
Vancouver0
Yellow Knife0
London0
Victoria0
Toronto2271
 
 I don't want the 0's to show up. I should only get 0's when I add Total Loans similar to Expected Output B.
6 REPLIES 6
mussaenda
Super User
Super User

If I am not mistaken, you can filter the total deposits in filters pane to something like this (refer to picture)

Assumming that the document type is your total deposits column. You can apply it on the visual level filters too if you want

Untitled.png

Anonymous
Not applicable

Hi @mussaenda , I can but I was looking for 1 formula to be able to do both

v-danhe-msft
Employee
Employee

Hi @Anonymous ,

From your description, I could not understand I want the output A & B. It seemed hard to show the A and B in the same visual, if you want to show with different tbale, you could refer to below steps:

A is your formula:

1.PNG

Create below measues for B:

Total Deposits +0 = CALCULATE(SUM(Table1[CAD Amount]), FILTER('Table1','Table1'[Budget Category]="Deposit") )+0
Total Loans+0 = CALCULATE(SUM(Table1[CAD Amount]), FILTER('Table1','Table1'[Budget Category]="Loan") )+0

Result:

1.PNG

You could also download the pbix file to have a view.

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

@v-danhe-msft  I want to use the same formula for both A & B.

You may use same formula if you prefer (for whatever reason) and for the visual A, apply an visual level filter (Advanced) on Total Deposits to filter out the records where Total Deposits is blank or Total Deposits is 0.

Hi @Anonymous ,

Sorry, I am afraid it could not use the same formula to not show 0 in A and show 0 in B.

 

Regards,

Daniel He

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

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.