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

How to retrieve 2 Selected values and use both values in a measure Calculation ?????

Hello everyone,

So I have a problem with my dash and I don't know if there's actually a solution; I want to retrieve the selected values of a slicer and use those values inside a calculated column, so far everything I tried doesn't seem to work. To put you in context, I'm trying to see all the tasks that passed from a "Status 1" to "Status 2" in a table, i've created a column called Transition status : 

TransitionStatus =
VAR CurrentStatus = 'Task History'[projects.note_status_history.status_title]
VAR NextStatus =
    CALCULATE(
        FIRSTNONBLANK('Task History'[projects.note_status_history.status_title], 1),
        FILTER('Task History', 'Task History'[projects.note_status_history.note_id] = EARLIER('Task History'[projects.note_status_history.note_id]) && 'Task History'[New date] > EARLIER('Task History'[New date]))
    )
RETURN
    IF(
        CurrentStatus ="Status 1" && NextStatus ="Status 2",
        "Status 1 to 2",
        "Other"
    )

When I explicitly write "Status 1" and "Status 2" in the calculation (like the example above), everything works. but when i replace '' CurrentStatus ="Status 1" && NextStatus ="Status 2" '' with for example "CurrentStatus = SM && NextStatus =FM" it doesn't work. the value SM and FM are measures within the table. 

I want to be able to change the values of CurrentStatus & NextStatus from outside the formula (from a slicer SELECTEDVALUES for example).

INFO : currentStatus and NextStatus are values from the same Column or Slicer. 

I appreciate any kind of help! Thank you.
3 REPLIES 3
Othmane26
Frequent Visitor

Othmane26
Frequent Visitor

I'm actually looking to select all the Tasks that their Status passed from a "Status 1" to "Status 2". If I replace "&&" with "OR", I will have both tasks that are "Status 1" and never had a "Status 2" and also tasks with "Status 2" but never were "Status 1".

The tutorial you gave me doesn't respond to what I need, I'll explain better : 
I want to be able to retrieve the values of CurrentStatus and NextStatus dynamically; meaning I want to select the CurrentStatus and NextStatus from a slicer (or maybe from something else if that was possibe). 
If on a slicer I select "Status 4" and "Status 5" for example, i want the values selected to be placed inside the formula I posted in the last block. so we'll have :

    IF(
        CurrentStatus ="Status 4" && NextStatus ="Status 5",
        "Status 1 to 2",
        "Other"
    )


I hope the problem is very clear now.

Thank you in advance.

amitchandak
Super User
Super User

@Othmane26 , it should be or not end

 

IF(
CurrentStatus ="Status 1" ||  NextStatus ="Status 2",
"Status 1 to 2",
"Other"
)

 

and can be there at a level

example

And for Selected Values, All selected values are present: https://youtu.be/X5T4rIZovHk

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.