Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hi, I don't understand how my var PosNeg get the value for sign for each line of the table ?
I thougth that the var was "constant" in the code.
FV =
var PosNeg = MIN( MaTable[Signe])
var result =
switch ( SELECTEDVALUE(MaTable[Libellé]),
"A",sum(MaTable[Valeur])*PosNeg,
"B",sum(MaTable[Valeur])*PosNeg,
"C",sum(MaTable[Valeur])*PosNeg,
"D",sum(MaTable[Valeur])*PosNeg
)
return result
I 've got this result whith the Dax code :
Solved! Go to Solution.
Hi @GuillaumePower
Each cell in the table visual has it's own filter context. In you example the first cell is subjected to a filter context that contains 'Table'[Libelle] IN { "A" } and so on. Measures are evaluated in each cell independently, therefore, the variable will be evaluated differently in each cell based on its filter context. However, inside a particular cell the variable is evaluated only once and cannot be recalculated. For example, the following measure will return SUM ( 'Table'[Column1] ) and the ALL modifier will not have any effect on the variable as it will never be recalculated hence the first evaluation will always be returned.
Measure =
VAR A = SUM ( 'Table'[Column1] )
RETURN
CALCULATE ( A, ALL ( 'Table'[Column2] ) )
Hi @GuillaumePower
Each cell in the table visual has it's own filter context. In you example the first cell is subjected to a filter context that contains 'Table'[Libelle] IN { "A" } and so on. Measures are evaluated in each cell independently, therefore, the variable will be evaluated differently in each cell based on its filter context. However, inside a particular cell the variable is evaluated only once and cannot be recalculated. For example, the following measure will return SUM ( 'Table'[Column1] ) and the ALL modifier will not have any effect on the variable as it will never be recalculated hence the first evaluation will always be returned.
Measure =
VAR A = SUM ( 'Table'[Column1] )
RETURN
CALCULATE ( A, ALL ( 'Table'[Column2] ) )
It is constant in that it is only evaluated once within the measure, but the measure itself is being evaluated for each row of your table. If you want to get the minimum across all rows you need to use REMOVEFILTERS(),
FV =
VAR PosNeg =
CALCULATE ( MIN ( MaTable[Signe] ), REMOVEFILTERS () )
VAR result =
SWITCH (
SELECTEDVALUE ( MaTable[Libellé] ),
"A", SUM ( MaTable[Valeur] ) * PosNeg,
"B", SUM ( MaTable[Valeur] ) * PosNeg,
"C", SUM ( MaTable[Valeur] ) * PosNeg,
"D", SUM ( MaTable[Valeur] ) * PosNeg
)
RETURN
result
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
18 | |
15 | |
14 | |
11 | |
8 |
User | Count |
---|---|
25 | |
21 | |
12 | |
11 | |
10 |