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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Levii
New Member

Calling a semaphore measure in a new measure ; switch/ifcode

Hello all, 

I have a measure that calculates semaphore value based on Target column and Value column, but it works on single filter selection.

 

Now i want to create a new measure that will call upon semaphore one and do next logic:

 

If ,for two selected KPI (semaphore values), one is green and other is yellow or black ,then display green sempahore otherwise red one..

I've tried muliple things but each time it only works for single selection of filter....probably because of SELECTEDVALUE function.

 

Any help suggestion is welcomed!

 

Semaphore measure:

 

 

Semaphores NEW 2024 YTD =

 

VAR CurrentMonth = MONTH(TODAY())

 

VAR JanToCurrentMonthVALUE = CALCULATE(

    SUM('Actual_2024'[Value]),

    FILTER(

        'Actual_2024',

        'Actual_2024'[Month] >= 1 &&  'Actual_2024'[Month] <= 12

    ),'Actual_2024'[Month] <= CurrentMonth

 

)

var notisblank = CALCULATE(COUNTROWS('Actual_2024'),FILTER(Actual_2024,Actual_2024[Month]>= 1 && Actual_2024[Month]<= 12), NOT(ISBLANK('Actual_2024'[Value])))

 

var JanToCurrentMonth =

DIVIDE(JanToCurrentMonthVALUE,notisblank)



// VAR JanToCurrentMonthTArget = CALCULATE(

//     SUM('Targets_2024'[Target]),

//     FILTER(

//         'Targets_2024',

//         'Targets_2024'[Month] >= 1 &&  'Targets_2024'[Month] <= 12

//     ),'Targets_2024'[Month] <= CurrentMonth-1

 

// )



// var Target =

// DIVIDE(JanToCurrentMonthTArget,notisblank)

 

var TargetX =CALCULATE(CALCULATE(SUM(Targets_2024[Target]),Targets_2024[Month]2024))

 

VAR FourPercentage = TargetX / 20

 

VAR FourPercentageAbs = ABS(FourPercentage)

RETURN

 IFSELECTEDVALUE('CpC KPIs_2024'[Semaphore]) = "G" ,

    IF(ISBLANK(JanToCurrentMonth) , ""  /*"#808080"*/ ,

    IF(ISBLANK(TargetX) , "" /*"#808080"*/ ,

    IF(JanToCurrentMonth >= TargetX , "🟢" /* "#67BB06" */ , /* green */

        IF((JanToCurrentMonth-TargetX)* -1  <= FourPercentage , "🟡" /*"#fffb00"*/ ,/* yellow */

            "🔴" /* "#F00202" */  /* red */

        )) )),

    /* RED ABOVE TARGET */

    IFSELECTEDVALUE('CpC KPIs_2024'[Semaphore]) = "R" ,

    IF(ISBLANK(JanToCurrentMonth) , "" /*"#808080"*/ ,

    IF(ISBLANK(TargetX) , "" /*"#808080"*/ ,

    IF(JanToCurrentMonth <= TargetX , "🟢" /* "#67BB06" */  /* green */  ,

        IF((JanToCurrentMonth-TargetX)  <= FourPercentage ,"🟡"  /* "#fffb00" */ ,/* yellow */

            "🔴" /* "#F00202" */  /* red */

        )) )),""))

 

 

 

__________________

1000051045.png

1000051046.png

1 REPLY 1
lbendlin
Super User
Super User

You cannot measure a measure directly. Either materialize it first, or create a separate measure that implements the entire business logic.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.