Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi Everyone, I have created a measure which calculates KPI based on selection in Slicer; when the particular product "A" or "B" or "C" is selected then the measure value returns, but when I have two different values selected in slicer like (A and B) - my calculated measure returns an error. My Slicer has distinct values like A,B,C to make selection. Please suggest - Below is my calculated measure :
TARGET =
IF (
ISCROSSFILTERED ( Product[Product_Type] ),
SWITCH (
TRUE (),
VALUES ( Product[Product_Type] ) = "A",
(
(
CALCULATE ( SUM ( RM[Dollar] ), RM[STATE] <> "TX", YEAR ( RM[Date] ) = 2020 ) / 12
) * 1.10
)
+ (
(
CALCULATE ( SUM ( RM[Dollar] ), RM[STATE] = "TX", YEAR ( RM[Date] ) = 2020 ) / 12
) * ( 0.43 )
),
VALUES ( Product[Product_Type] ) = "B",
(
(
CALCULATE ( SUM ( RM[Dollar] ), YEAR ( RM[Date] ) = 2020 ) / 12
) * 1.07
),
VALUES ( Product[Product_Type] ) = "C",
(
(
CALCULATE ( SUM ( RM[Dollar] ), YEAR ( RM[Date] ) = 2020 ) / 12
) * 1.10
),
BLANK ()
),
BLANK ()
)
@Greg_Deckler,@v-jiascu-msft @Anonymous @selimovd @Fowmy @amitchandak @parry2k @Jihwan_Kim
Solved! Go to Solution.
@Longdisplay I will revisit this measure and maybe rewrite it this way. Again, please double-check the results.
TARGET =
IF (
ISCROSSFILTERED ( Product[Product_Type] ),
SUMX ( VALUES ( Product[Product_Type] ) ),
SWITCH (
Product[Product_Type],
"A",
(
(
CALCULATE ( SUM ( RM[Dollar] ), RM[STATE] <> "TX", YEAR ( RM[Date] ) = 2020 ) / 12
) * 1.10
)
+ (
(
CALCULATE ( SUM ( RM[Dollar] ), RM[STATE] = "TX", YEAR ( RM[Date] ) = 2020 ) / 12
) * ( 0.43 )
),
"B",
(
(
CALCULATE ( SUM ( RM[Dollar] ), YEAR ( RM[Date] ) = 2020 ) / 12
) * 1.07
),
"C",
(
(
CALCULATE ( SUM ( RM[Dollar] ), YEAR ( RM[Date] ) = 2020 ) / 12
) * 1.10
),
BLANK ()
) --switch closing
), --sumx closing
BLANK ()
)
Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@Jihwan_Kim But that is not a true fix, it will not work if user selects more than one value, better to have multiple values selected, and show sum as @Longdisplay illustrated in his screenshot. Just my 2 cents.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
In my opinion, instead of using VALUES, try using SELECTEDVALUES.
In that case, I think, if more than two products are selected in the slicer, it will return a blank.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Schedule a short Teams meeting to discuss your question
@Longdisplay I will revisit this measure and maybe rewrite it this way. Again, please double-check the results.
TARGET =
IF (
ISCROSSFILTERED ( Product[Product_Type] ),
SUMX ( VALUES ( Product[Product_Type] ) ),
SWITCH (
Product[Product_Type],
"A",
(
(
CALCULATE ( SUM ( RM[Dollar] ), RM[STATE] <> "TX", YEAR ( RM[Date] ) = 2020 ) / 12
) * 1.10
)
+ (
(
CALCULATE ( SUM ( RM[Dollar] ), RM[STATE] = "TX", YEAR ( RM[Date] ) = 2020 ) / 12
) * ( 0.43 )
),
"B",
(
(
CALCULATE ( SUM ( RM[Dollar] ), YEAR ( RM[Date] ) = 2020 ) / 12
) * 1.07
),
"C",
(
(
CALCULATE ( SUM ( RM[Dollar] ), YEAR ( RM[Date] ) = 2020 ) / 12
) * 1.10
),
BLANK ()
) --switch closing
), --sumx closing
BLANK ()
)
Check my latest blog post Comparing Selected Client With Other Top N Clients | PeryTUS I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hey @Longdisplay ,
you get the error because you are checking with multiple selections a list returned by VALUES to a string, for example "A".
As long as there is only one value that works as it's transformed to a single row, but when there are more values you will get an error.
First I would change the VALUES ( Product[Product_Type] ) to MAX( Product[Product_Type] ). This should fix the error.
If you really want to select only one value, I would already change the slicer to single selection:
Hi @selimovd ; I am getting inaccurate total from calculated measure when I have Product A and Product B Selected together - for example
Total (from measure) | 143,661 |
Product A | 129,642 |
Product B | 17,555 |
Accurate Total should be | 147,197 |
Can you please suggest?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
19 | |
14 | |
13 | |
11 | |
8 |