Forum Discussion
Replacing blank values with zero
- 4 years ago
ronaldbalza2023 You're converting the 0s to blanks with the P&L (no blanks) measure. Are you saying you want that back to 0? Can you simply use the P&L measure?
The problem is, that you have a matrix so it will replace ALL rows with zero - how do you specify which rows you want to show or not?
You may be able to work with an IF() statement, but we need to know which columns you're using in that matrix visual please and you could use that context to filter out rows where the total row is blank, otherwise put 0 - is that what you mean?
- 4 years ago
ronaldbalza2023 Sorry, I was trying with a simplified version of [P&L] but you're right it doesn't work in your measures.
Try updating the [P&L (No Blanks)] measure and use that in your visual instead:
P&L (No Blanks) =VAR _ColSubTotal = CALCULATE([P&L], ALL(DimAccount[Account Type), ALL(DimAccount[Name]))VAR _Result =IF(_ColSubTotal <> 0, [P&L])RETURN _ResultI don't know what table the Account Type and Name are coming from, so you may need to update that part of the measure. - 4 years ago
ronaldbalza2023 I thought your [P&L] measure already had the $0 included in it? So the $0 should display if you've got the ColSubtotal part correct....
You could try adding the zero back in:
P&L (No Blanks) =VAR _ColSubTotal = CALCULATE([P&L], ALL(DimAccount[Account Type), ALL(DimAccount[Name]))VAR _Result =IF(_ColSubTotal <> 0, [P&L]+0)RETURN _Result - 4 years ago
That's because they are blank for that account type. Do you have a DimAccount table?
Can try replacing the ALL filters with just
ALL(DimAccount)
- 4 years ago
Hi AllisonKennedy , hooray! after a gruelling nights spending time with this 🙂 Thanks so much for your help.
Hi TheoC , thanks for taking the time on this. It works however, all the columns that has zero values appeared and the totals column on the far right disappeared. How can I removed the columns with zero values and bring back the totals column? I have filtered the values that is not 0.
Hi ronaldbalza2023, did you remove the +0 from your measures?
- ronaldbalza20234 years agoContinued Contributor
TheoC yes Sir, I did. Still the same.
- TheoC4 years agoCommunity Champion
If the below doesn't work, then there is something else that may be the issue mate. The logic is based on your formula, filters and relationships. All the adjustment is doing is saying return 0 if it's blank, else return the output. Without having access to the PBIX, it will be difficult for me to be of any assistance and I'd be wasting your time... sorry ronaldbalza2023
P&L = IF ( ( CALCULATE ( SUM ( 'Invoices'[Line Amount FX Calculation] ), FILTER ( 'Accounts', Accounts[Class] = "Revenue" || Accounts[Class] = "Expense" ), USERELATIONSHIP( Invoices[Invoice Line ID], 'Tracking Category CONNECTIONS'[ID]) ) ) - [P&L - Credit Notes] + [P&L (Journals)] ) = 0 , 0 , ( CALCULATE ( SUM ( 'Invoices'[Line Amount FX Calculation] ), FILTER ( 'Accounts', Accounts[Class] = "Revenue" || Accounts[Class] = "Expense" ), USERELATIONSHIP( Invoices[Invoice Line ID], 'Tracking Category CONNECTIONS'[ID]) ) ) - [P&L - Credit Notes] + [P&L (Journals)] )
- ronaldbalza20234 years agoContinued Contributor
TheoC when I use blank(), it removes the columns with zeroes and the total columns appears. However, I wanted to fill these blanks here with zero.
- TheoC4 years agoCommunity Champion
ronaldbalza2023, try using
IF ( ISBLANK ( [P&L] ) , 0 , [P&L] )