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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors