Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Philip-K
Frequent Visitor

Printing 0-values with summarize

I use one large data file in which all incidents are reported. Both the incident and the impact of the incident is reported in this source file. To calculate the moving average over several months, I use the SUMMARIZE function to create a new table. In this table I either count the IDs summarized by YearMonth column, or I SUM the impact of the incidents summarized by the YearMonth column. Then I proceed calculating the moving average.

 

The issue I'm having is the following: When a month has 0 incidents, it is not recorded as a value. I would like to summarize all the months and print a 0-value for months in which no incidents occured (with the specific filter).

 

Here is the formula I use to summarize the data:

M2.1 = SUMMARIZE(CALCULATETABLE(Incidents;Incidents[Category]="D3";Cause[Scope]=1;'Impact level'[Impact level]<=4);Incidents[YearMonth];"Summed impact per incident";SUM(Incidents[Impact]))

 

The Date column:

Date = DATE(LEFT('M2.1'[YearMonth];4);RIGHT('M2.1'[YearMonth];2);1)

 

And to calculate moving average:

Moving average =
var startdate=Min('M2.1'[Date])+334 
var date = 'M2.1'[Date] 
var d365 = EDATE(date;-12) 
var r=
IF(date>=startdate; 
AVERAGEX( FILTER('M2.1'; 'M2.1'[Date] <= date && 'M2.1'[Date] > d365); 
'M2.1'[Summed impact per incident] )
)
RETURN
r

 

 

Any help is appreciated!

1 ACCEPTED SOLUTION

Hi,

 

I recently figured out how to solve the problem I was having. If I break it down, the real problem was that I wanted the table I create (as a summary of all the data in the master data file) did not show the months in which no data was recorded. So what I did is the following:

I created a static table with all the YearMonth combinations for the forseeable future and recorded past. (i.e. 2013-01 untill 2050-12)

 

Then I created a new calulated table with the DAX: Distinct(YearMonth) to print every individual value into this table.

 

Following I created an IF calculation on the SUM (and separately COUNT) of the incidentents in the following way:

IF(CALCULATE(SUM(<incidents>);<filters>)=blank();0;

CALCULATE(SUM(<incidents>);<filters>))

 

It works perfectly in this situation. Because this situation called for a moving average calculation over several fillers on data, I couldn't find a way to use the measure functionality. I would love to see the moving average be a feature in the visualization level in some future release. My opinion on the matter is that this should be Chart-functionality, not something I need to calculate myself.

View solution in original post

4 REPLIES 4
v-caliao-msft
Microsoft Employee
Microsoft Employee

Hi @Philip-K,

 

Please elaborate your data model structure and provide us some sample data, so that we can make further analysis.

 

Regards,

Charlie Liao

Hi,

 

I recently figured out how to solve the problem I was having. If I break it down, the real problem was that I wanted the table I create (as a summary of all the data in the master data file) did not show the months in which no data was recorded. So what I did is the following:

I created a static table with all the YearMonth combinations for the forseeable future and recorded past. (i.e. 2013-01 untill 2050-12)

 

Then I created a new calulated table with the DAX: Distinct(YearMonth) to print every individual value into this table.

 

Following I created an IF calculation on the SUM (and separately COUNT) of the incidentents in the following way:

IF(CALCULATE(SUM(<incidents>);<filters>)=blank();0;

CALCULATE(SUM(<incidents>);<filters>))

 

It works perfectly in this situation. Because this situation called for a moving average calculation over several fillers on data, I couldn't find a way to use the measure functionality. I would love to see the moving average be a feature in the visualization level in some future release. My opinion on the matter is that this should be Chart-functionality, not something I need to calculate myself.

hohlick
Continued Contributor
Continued Contributor

Hi @Philip-K

You can make it shorter, I think:

 

CALCULATE(SUM(<incidents>);<filters>)+0

Maxim Zelensky
excel-inside.pro

Great addition, thanks!

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.