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
sbrazeau
Frequent Visitor

Comparing current year to previous when there is no data this year

Hello.

 

I am building a set of reports for the company I work for.  Almost done, I realize there is a problem.  I need to compare incidents and accidents between either years or periods.  Everything seemed to work fine, until I realised I am missing data once in a while.  To make an easy example, my tables would look like this:

 

yearstype of accident
2019A
2019A
2019B
2019C
2018B
2018B
2018C
2018C
2017A
2017C
2017C

 

My reports let you select a year and it will show a table with the count of accidents for the selected year and the priopr year (SAMEPERIODLASTYEAR). So if I select 2019, I get:

yearsABC
2019211
2018022

 

If I select 2018, this is where I get the problem.  Since there is no "A" in 2018, "A" does not get evaluated and the returned table is:

yearsBC
201822
201702

 

instead of:

yearsABC
2018021
2017102

 

Is there a function that would force the table to consider all values of the SAMEPERIODLASTYEAR and not only the current year?

 

Thanks!

2 REPLIES 2
MauriceMecowe
Resolver II
Resolver II

Hi sbrazeau,

 

Maybe the ISBLANK() function is what you're looking for. Or you can build out a query where with a filter clause. It will look something like:

 

[Comparison over time] :=
CALCULATE(
	[Value],
	FILTER(
		ALL('Date'),
		CONTAINS(
			VALUES, ('Date'[Date])
			'Date'[Date],
			'Date'[Date]
			)
		)
	)
 

Unfortunately, I don't think the ISBLANK() would do the trick since there is no blank entry in the table.  The problem is really that if my COUNTA=0 this year, the report does not care about last year.

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.

Top Solution Authors