Power BI: calculate values for a specific object and show 0 instead of blank

This DAX formula will get the total of a specific value, in my example, I am asking to calculate the total for the second quarter of 2021

CALCULATE(SUM('table'[argument]),'table'[argument]="xxx")

NOTE: change “table”, “argument” and "xxx" by yours. As you can see in the picture, I put mine.

power bi

To see the result, first I will create a measure by clicking on “home -> new measure” and put the formula. Secondly, I will create a “card” in the visualization and in the “fields”, I put the “measure”. And in case if there is no result, instead to get a blank, with this one, I am asking to put zero:

var blank0=CALCULATE(COUNT('table'[argument]),'table'[argument]="xxx")
return
IF(ISBLANK(blank0),0,blank0)

NOTE: to count unique value, use “DISTINCTCOUNT” instead of “COUNT”.

The difference between “sum” and “count” is that for “sum”, the argument should be a number column (for instance 1, 52, etc.) and for “count”, a text column (for instance, inc001, inc002, etc.)

power bi
power bi power bi

Interesting Management