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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Lazarosper
Regular Visitor

What is wrong with my DAX Measure?

Hello guys so this is my Dax code

 

testin1 =
IF (
(
SELECTEDVALUE('Campaign Lookup'[Campaign]) IN { "A", "B", "C" }
&&
(
SELECTEDVALUE('Campaign Lookup'[Placement]) = "DEMANDGEN"
||
SELECTEDVALUE('Campaign Lookup'[Placement]) = "PMAX"
||
(SELECTEDVALUE('Campaign Lookup'[Placement]) = "DEMANDGEN" && SELECTEDVALUE('Campaign Lookup'[Placement]) = "PMAX")
)
),
DIVIDE([Total Cost], [Total Budget Cost]),
0
)

 

 

What values i would like to get is that when the user select from the campaign slicer any of this 3 values AND from the placement slicer any of this 2 values to get 0 ,the code works fine when it comes if the user select 1 of the 2 values from the placement slicer but if they select both it doesnt return 0 as i would expect.Why is that?

1 REPLY 1
lbendlin
Super User
Super User

SELECTEDVALUE is exactly ONE value. You could use VALUES() or you could refactor your code.

 

testin1 =
IF (SELECTEDVALUE ( 'Campaign Lookup'[Campaign] ) IN { "A", "B", "C" }
    && SELECTEDVALUE ( 'Campaign Lookup'[Placement] ) IN  {"DEMANDGEN", "PMAX"},
    DIVIDE ( [Total Cost], [Total Budget Cost] ),
    0
)

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.