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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
ecoflux38170
Regular Visitor

Problem with negative index on table

Hello everyone,

I am new to PowerBI.
I have a problem with a measure, here is the source of my measure:

Kilométrage =
IF(
ISFILTERED('Chronologie'[Chronologie]),
ERROR("Les mesures rapides de Time Intelligence peuvent être regroupées ou filtrées seulement par la hiérarchie de dates ou les colonnes de dates principales fournies par Power BI."),
VAR __PREV_YEAR = CALCULATE([Index kilométrique(km)], DATEADD('Chronologie'[Chronologie].[Date], -1, YEAR))
RETURN
('Index Kilométrique'[Index kilométrique(km)] - __PREV_YEAR))
I would like to cancel the calculation if one of the values ​​is negative to calculate the number of kilometers of the vehicles in my fleet.
How to do?
Thank you in advance for your help!

Capture d’écran 2023-03-14 152442.png
Capture d’écran 2023-03-14 152549.png

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@ecoflux38170 Try:

Kilométrage = 
IF(
ISFILTERED('Chronologie'[Chronologie]),
ERROR("Les mesures rapides de Time Intelligence peuvent être regroupées ou filtrées seulement par la hiérarchie de dates ou les colonnes de dates principales fournies par Power BI."),
VAR __PREV_YEAR = CALCULATE([Index kilométrique(km)], DATEADD('Chronologie'[Chronologie].[Date], -1, YEAR))
VAR __Value = ('Index Kilométrique'[Index kilométrique(km)] - __PREV_YEAR))
VAR __Result = IF(__Value < 0, BLANK(), __Value)
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@ecoflux38170 Try:

Kilométrage = 
IF(
ISFILTERED('Chronologie'[Chronologie]),
ERROR("Les mesures rapides de Time Intelligence peuvent être regroupées ou filtrées seulement par la hiérarchie de dates ou les colonnes de dates principales fournies par Power BI."),
VAR __PREV_YEAR = CALCULATE([Index kilométrique(km)], DATEADD('Chronologie'[Chronologie].[Date], -1, YEAR))
VAR __Value = ('Index Kilométrique'[Index kilométrique(km)] - __PREV_YEAR))
VAR __Result = IF(__Value < 0, BLANK(), __Value)
RETURN
  __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks for your solution ! It Works but now, sums are wrong, but it's the sums that interest me the most. I make another post for this other problem.

ecoflux38170_0-1679641796419.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.