cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sphillips22 Advocate II
Advocate II

Re: show items with no data as 0 instead of blanks

@Aks-1  for your question about the quadrants showing blanks, can you please post the dax formula that corresponds to it?

Aks-1
Frequent Visitor

Re: show items with no data as 0 instead of blanks

Hi @sphillips22 ,

                                Thank you so much for the response .The DAX formula I am using is 

CALCULATE( SUM(POC[Money_Paid]), FILTER( ALL(POC), POC[ACCTG_Period] <= MAX(POC[ACCTG_Period]) ), VALUES(POC[LY])+0

 

Please note for data that has no value in the row it displays as 0.00 as shown in the screenshot but since the header part is derived it does not have data in database which I would like to display as 0.00 instead of Blank.

 

 

Thanks.

sphillips22 Advocate II
Advocate II

Re: show items with no data as 0 instead of blanks

@Aks-1  a little tough to determine without seeing the table defitions, however, I would start by removing the VALUES() clause at the end of the CALCULATE function. The new dax measure would read as below:

 

Measure:=

CALCULATE(

  SUM(POC[Money_Paid]),

  FILTER( ALL(POC), POC[ACCTG_Period] <= MAX(POC[ACCTG_Period]) )

) + 0

 

It may also be that you need to use the "+ 0" after the closing paranthesis of the CALCULATE function.

By utilizing the VALUES function, you are effectively filtering the CALCULATE function to apply to only the unique "LY" values in the POC table. This may be causing the undesired result of blank values, for those LY values that are not in POC table.

 

Let me know if that works for you.

 

mdawesdigitalk
Frequent Visitor

Re: show items with no data as 0 instead of blanks

 

I also have a similar issue that I just can't get my head around..and the "+0" method hasn't solved it.

 

I have a complex model, but for this purposes have stripped it backed to simple basics, and still can't resolve it, even though I have previously I think.

 

In simple terms we have a customer base which is not active in every month on every product.

 

Therefore when comparing one month of Sales with another, you get blank entries in the database as part of the dataload relating to Customers, such as follows (removing the product variable to keep things even simplier);

 

1 table (DATA) with 3 Members as follows Customer, Month and Sales

 

Cust1, Month1, 100

Cust1, Month2 ,200

Cust1, Month3, 50

Cust2, Month1, 75

Cust2, Month3, 40

Cust3, Month2, 78

Cust3, Month3, 80

 

So Cust1 is active is all Months, Cust2 active in all months but Month2, and Cust3 active is all months but Month1.

 

My issue is that I'm trying to generate a simple Sales Variance (current month - previous month) report across all months for all Customers.  My totals balance, but the analysis by Customer is missing rows where when the Customer is not active in the "Current Month" - example table below for Month 2 as Current Month

 

Cust1 CntMth = 200, PrvMth = 100, SalesMove = 100

Cust3 CntMth = 78, PrvMth = 0, SalesMove = 78

Totals CntMnth = 278, PrvMnth = 175, SalesMove = 103

 

What is missing is the Cust2 line of CntMnth = blank (and so not included), PrvMnth 75, SalesMove = -75

 

[Note in my model I have actual dates of "01/09/2019, 01/10/2019, 01/11/2019" respectively but have kept things generic here.] 

 

The measures that I have used are as follows but the adding "+0" has not solved the issues as the blanks remain;

 

CntMnth = CALCULATE(sum(DATA[Sales]), DATEADD(DATA[Month],0,MONTH)) + 0

PrvMnth = CALCULATE(sum(DATA[Sales]), DATEADD(DATA[Month],0,MONTH)) + 0

SalesMove = CALCULATE([CntMnth] - [PrvMnth]) + 0

 

Any guidance, which I assume is very basic and simple, appreciated, as I've just got a total block on this, and shouldn't have...

 

Thanks

 

Mark

 

Sean Community Champion
Community Champion

Re: show items with no data as 0 instead of blanks

@mdawesdigitalk 

You don't need to add a zero to calculate current vs previous if that's all you are trying to do.

The Measures you've listed for current and previous look exactly the same?! (except for the Measure Names)

Dateadd only works if you have a list of consecutive dates so I would assume you have a calendar table.

Note that the Current and Previous Measures reference the Date column in the Calendar table in the example below that would be 'Date'[Date]

However, I would not use dateadd in this case.

Rather I would create these 4 Measures

 

Sales Amount = SUM ( Data[Sales] )

Current Month = TOTALMTD ( [Sales Amount], 'Date'[Date] )

Previous Month = CALCULATE( [Sales Amount], PREVIOUSMONTH ( 'Date'[Date] ) )

Cur - Prev = [Current Month] - [Previous Month]

 

 The final measure should provide you the result you are looking for.

 

Hope this helps! 🙂

anni Helper I
Helper I

Re: show items with no data as 0 instead of blanks

Hi, 

 

Is there any idea how to reflect "0" when there is a list of countries in the table, but one country has no results at all? 
The goal is to show that all countries have smth even if it just zero, so the bad result would push it to add some products too. 

 

I cannot even see the country in the table I get from database via Power bi, but i know it is there 🙂 

Balashenbak
Frequent Visitor

Re: show items with no data as 0 instead of blanks

Thanks it worked

tonymaclaren Helper I
Helper I

Re: show items with no data as 0 instead of blanks

Hi 

There is  an even cleaner solution using the new COALESCE Dax command. No CALCULATE required:

ActualM :=
COALESCE ( SUM ( Expenses[Actual] )0 )   

You can make it even more powerful:

	
COALESCE ( [MyMeasure], [DefaultMeasure] )

 Please mark as a solution.

Sean Community Champion
Community Champion

Re: show items with no data as 0 instead of blanks

You do realize that your "even more powerful" solution could still return blank right?

Unless you add a zero as a 3rd argument or each of your 2 measures address how to handle blank on their own.

 

Go back and read the paragraph right under the "even more powerful" solution you copied from here...

https://www.sqlbi.com/articles/the-coalesce-function-in-dax/ 

 

 

tonymaclaren Helper I
Helper I

Re: show items with no data as 0 instead of blanks

Hi

First of all, dont use (values)/10 use DIVIDE(Values),10) or you could get a divide by zero error.

 

try:

 

 

My Measure :=
VAR Values =
    SUM ( 'table name'[Column name] )
RETURN
    COALESCE ( DIVIDE ( Values, 10 ), 0 )

 

 

This will avoid the possibility of divide by zero, which is good practice and give you a zero if there is no data

 

 

 

Helpful resources

Announcements
Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

April 2020 Community Highlights

April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors