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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Pier2
Helper I
Helper I

Variable strange behavior in a measure, report only if substract a number

Hello,

I have a variable in a measure who returns a value only if I put a minus number at its end but nothing otherwise.

I use integer to identify years.

I want to report a trend, minus the year cicled in red.

Pier2_0-1719357232378.png

The formula is the following to be sure to see the entire graphic:

m_CoutCapitauxPropres = 

VAR varPrem = 
CALCULATE(
    MIN(tblEntrepriseDonnees[intAnnee]), USERELATIONSHIP(tblEntreprise[KEntreprise],
    tblEntrepriseDonnees[FKEntreprise]) 
)-1
     
RETURN



CALCULATE(
SUM(tblEntrepriseDonnees[sglCoutCapitauxPropres]),
FILTER(
CalendrierAnnuel,
CalendrierAnnuel[Année fiscale]  > varPrem
), USERELATIONSHIP(tblEntreprise[KEntreprise],
    tblEntrepriseDonnees[FKEntreprise])
)

 

Should I simply replace -1 for nothing, zéro or +1, everything vanish.

m_CoutCapitauxPropres = 

VAR varPrem = 
CALCULATE(
    MIN(tblEntrepriseDonnees[intAnnee]), USERELATIONSHIP(tblEntreprise[KEntreprise],
    tblEntrepriseDonnees[FKEntreprise]) 
) // Nothing is substracted or added to the evaluation
     


What's the logic behind that behavior? How to solve it? The best solution, for me would be to replace -1 for nothing.


1 ACCEPTED SOLUTION

Hello @v-junyant-msft ,

Thanks for your help.

That formula returns effectively a value, which is the right value in its context, the year 2015. That's something I already verified in different ways.

Pier2_0-1719582547962.png

In the RETURN part of my formula, should I change the variable varPrem for an integer (2015, for exemple) it works perfectly. It's like the variable varPrem doen't convey the value to the RETURN.

On the data side, the table looks like this. The year 2015 (the first of the graph) has no ratio calculated and when its the case, I try to get rid of it because that's meaningless. And I starting to believe it is the source of the problem but I don't know why.

intAnnee (year using integer)sglCoutCapitauxPropres
2015 
20160,04
20170,05
20180,00
20190,12

 

View solution in original post

2 REPLIES 2
v-junyant-msft
Community Support
Community Support

Hi @Pier2 ,

Could you please take this DAX out and create a measure to see whether it returns a null value?

CALCULATE(
    MIN(tblEntrepriseDonnees[intAnnee]), USERELATIONSHIP(tblEntreprise[KEntreprise],
    tblEntrepriseDonnees[FKEntreprise]) 
)

 
Best Regards,
Dino Tao

Hello @v-junyant-msft ,

Thanks for your help.

That formula returns effectively a value, which is the right value in its context, the year 2015. That's something I already verified in different ways.

Pier2_0-1719582547962.png

In the RETURN part of my formula, should I change the variable varPrem for an integer (2015, for exemple) it works perfectly. It's like the variable varPrem doen't convey the value to the RETURN.

On the data side, the table looks like this. The year 2015 (the first of the graph) has no ratio calculated and when its the case, I try to get rid of it because that's meaningless. And I starting to believe it is the source of the problem but I don't know why.

intAnnee (year using integer)sglCoutCapitauxPropres
2015 
20160,04
20170,05
20180,00
20190,12

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.