Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi, i need help!
I have the follow measure:
REAL = CALCULATE(
sum(BA_DIARIO[VLR_LANCAMENTO])/1000000,
LASTDATE(BA_DIARIO[DT_EXEC])
)
This one works fine and do what i need properly.
The issue comes now. I try to use them in the code like bellow:
Sum Switch =
SWITCH (
TRUE(),
SELECTEDVALUE ( BA_DIARIO[DC] ) = "△ REAL X BN", [REAL],
SUM ( BA_DIARIO[VLR_LANCAMENTO] )/1000000
)
it aways returns the sum of else statement.
Yes, i tested swap that measure [REAL] in SELECTEDVALUE ( BA_DIARIO[DC] ) = "△ REAL X BN", [REAL] by
Solved! Go to Solution.
@lucas_canova Ok, it's more clear. So try with create a new calculated table:
BBF
@lucas_canova Hi!
Try with:
Sum Switch =
SWITCH (
TRUE(),
SELECTEDVALUE(BA_DIARIO[DC]) = "△ REAL X BN", CALCULATE([REAL]),
SUM(BA_DIARIO[VLR_LANCAMENTO])/1000000
)
By wrapping [REAL] in a CALCULATE function, you force its evaluation in the context of the SWITCH statement.
BBF
Returns blank too
@lucas_canova Can you share the pbix file? Meanwhile you can try:
REAL = CALCULATE(
SUM(BA_DIARIO[VLR_LANCAMENTO])/1000000,
LASTDATE(BA_DIARIO[DT_EXEC])
)
Sum Switch =
SWITCH (
TRUE(),
SELECTEDVALUE(BA_DIARIO[DC]) = "△ REAL X BN",
CALCULATE(
SUM(BA_DIARIO[VLR_LANCAMENTO])/1000000,
LASTDATE(BA_DIARIO[DT_EXEC])
),
SUM(BA_DIARIO[VLR_LANCAMENTO])/1000000
)
BBF
@BeaBF, follow pbix bellow:
https://drive.google.com/file/d/1J27PzB6UynHcecdeCpBeanFQth19igvc/view?usp=drive_link
In final stage, i need to perform delta between [REAL] - [BN] measures in that switch statement. I posted only [REAL] for more ez compreension .
@lucas_canova the reason of always blank is that there is no VLR_LANCAMENTO value for DC = △ REAL X BN. Let's see the table:
because of blank values in VLR_LANCAMENTO, also REAL is Blank.
BBF
@BeaBF , swap in measure SELECTEDVALUE(BA_DIARIO[DC]) = "△ REAL X BN", [REAL] by
SELECTEDVALUE(BA_DIARIO[DC]) = "△ REAL X BN", 0. U will see what i'm talking. My logical is working, but idk how to handle with this dax issue to perform [REAL] - [BN].
@BeaBF that is the reason i'm using a measure to switch the blank value for a calculated one. I did it on another pbix and worked.. idk what im doing different
@BeaBF, I need the difference between last day, and bn 6 + 6, this diferrence need to born in "
First line for example the results must be -0.28
The measures [REAL] and [BN] perform this calculation. I just need [REAL] - [BN].
@lucas_canova Ok, it's more clear. So try with create a new calculated table:
BBF
@BeaBF Thx so much, idk why, but the solution comes from this buddy:
DT_TABLE = DISTINCT(BA_DIARIO[DT_EXEC])
when i try to use the max date from BA_DIARIO, and dont from this calculate table, i fall to the initial issue.
@lucas_canova to not use an external table for DT_EXEC, you can use:
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
23 | |
7 | |
7 | |
6 | |
6 |
User | Count |
---|---|
27 | |
12 | |
10 | |
9 | |
6 |