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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Dirkdr
New Member

Year over year index in table/matrix

Hello!

 

I would like to create multiple year-over-year indexes to compare a numerical value for a given period with the same period a year before. This also works well for column and line charts but I can't manage to use them in tables or matrices. My data kinda looks like the following:

 

datedevicecountrycostssales
11/1/2021tabletUS50250
11/1/2021desktopNO45300
11/1/2021mobileBE30350
11/1/2021mobileCA5200

 

The following DAX formula to create a measure works really well on a card or for example line or column charts:

 

Costs YoY Index = DIVIDE(SUM(data[costs]), CALCULATE(SUM(data[costs]), DATEADD(data[date], -1, YEAR))) * 100
 
However, when I try to create a table or matrix that shows something like the following:
 
CountryCostsCosts YoY Index
AE5500108
AO6540113
AR7839115
AT230085

 

I get the error: "Can't display the visual. See details" - MdxScript(model)(4,124) Calculation error in measure '_Calculations[Costs YoY Index]: Function 'DATEADD' expects a contiguous selections when date column is not unique, has gaps or contains time portion.

 

Does somebody know how to solve this? 

 

Great thanks!

4 REPLIES 4
Dirkdr
New Member

Hi @Anonymous ,

 

Thanks again for your reply. 

 

I can now indeed add it to my table. Unfortunately however the numbers don't make sense anymore now. Also changing the hierachy to month doesnt help as I get the same original error. 

Anonymous
Not applicable

Hi @Dirkdr ,

You can add date to the visual.

The measure is correct!  Just ensure that the date field in the visual .

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Hi @Anonymous,

 

Thank you for your reply! Adding the date field indeed fixes the error. 

 

However, my table gets very big when I add the date field as for every country and every date combination it is listed in the table. Ideally, I only want to show the following:

 

CountryCosts Costs YoY Index
AE5500108
AO6540113
AR7839115
AT230085

 

While when I add the date I get something like this:

 

CountryDate Costs Costs YoY Index
AE11/1/2021250102
AE11/2/2021320111
AE11/3/202140085
AE11/4/2021100120

 

Thanks a lot!

 

Anonymous
Not applicable

Hi @Dirkdr ,

You can modify the measure.

Costs YoY Index = var _1=year(maxx(all(data),date[date]))
return
DIVIDE(SUM(data[costs]), CALCULATE(SUM(data[costs]), year[date[date]=_1-1)) * 100

Or you can change the date hierarchy to the month.

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.