cancel
Showing results for 
Search instead for 
Did you mean: 
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
PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Top Solution Authors