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
bestevezdyb
Frequent Visitor

DAX SelectedValue With If

Good morning,

I would like to understand how to solve a problem that apparently is getting complicated. I have created a metric that is

NumberOfPizza =
VAR _qty = COUNTROWS( order_details )
RETURN
IF( _qty = BLANK(), 0, _qty)


And the next measure is 

SelectedValue =
SELECTEDVALUE( order_details[pizza_id] )

The result is as follow

 

bestevezdyb_0-1702805932532.png
bestevezdyb_1-1702806166138.png

 

How can I get the pizza type value to appear as a metric in the 0?

Thank you in advance
1 ACCEPTED SOLUTION

I think I have the solution

SelectedValue =
 
VAR _qty = [NumberOfPizza]
RETURN
IF(
    _qty = 0,
    CALCULATE(MAX(order_details[pizza_id]), REMOVEFILTERS(DimDate)),  -- Devuelve el valor de pizza_id si _qty es 0
    SELECTEDVALUE( order_details[pizza_id] )
)

View solution in original post

3 REPLIES 3
bestevezdyb
Frequent Visitor

@FreemanZ Thanks for reply. I need to show also the value that is at zero, something like this

bestevezdyb_0-1702835107831.png

 

I think I have the solution

SelectedValue =
 
VAR _qty = [NumberOfPizza]
RETURN
IF(
    _qty = 0,
    CALCULATE(MAX(order_details[pizza_id]), REMOVEFILTERS(DimDate)),  -- Devuelve el valor de pizza_id si _qty es 0
    SELECTEDVALUE( order_details[pizza_id] )
)
FreemanZ
Super User
Super User

hi @bestevezdyb ,

 

not sure if i really get you, try like:

SelectedValue = SELECTEDVALUE( order_details[pizza_id], 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.