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
cosminc
Post Partisan
Post Partisan

Measure with if with filtered value

Hi,

I try to create a measure based on a filter value and an if

something like this:

if(source(salesmen) slicer="George",4, if(source(salesmen) slicer ="Mary",0))

can you help me please with the correct syntax?

Thanks,

Cosmin

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

you need SELECTEDVALUE, I'd also consider wheter you want to use BLANK - calculation wise it acts as 0, display wise it acts as null

IF(
    SELECTEDVALUE(Source[Salesman]) = "George",
    4,
    IF(
        SELECTEDVALUE(Source[Salesman]) = "Mary",
        0,
        BLANK()
    )
)


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

4 REPLIES 4
Stachu
Community Champion
Community Champion

you need SELECTEDVALUE, I'd also consider wheter you want to use BLANK - calculation wise it acts as 0, display wise it acts as null

IF(
    SELECTEDVALUE(Source[Salesman]) = "George",
    4,
    IF(
        SELECTEDVALUE(Source[Salesman]) = "Mary",
        0,
        BLANK()
    )
)


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

Hi guys,

 

I do have a similar issue. This quick measure does not work. Does anyone have an idea?

 

Diff in % van Revenue Gross =
VAR __BASELINE_VALUE =
    CALCULATE(
        SUM('DWH'[Revenue Gross]),
            'DWH'[Delivery Date.Datum].[Jaar] IN {
IF(
SELECTEDVALUE(DWH[Delivery Date.Jaar]) = 2022,2021,
IF(
SELECTEDVALUE(DWH[Delivery Date.Jaar]) = 2021,2020,
IF(
SELECTEDVALUE(DWH[Delivery Date.Jaar]) = 2020,2019,
BLANK()
)
))}
    )
VAR __MEASURE_VALUE = SUM('DWH'[Revenue Gross])
RETURN
    IF(
        NOT ISBLANK(__MEASURE_VALUE),
        DIVIDE(__MEASURE_VALUE - __BASELINE_VALUE, __BASELINE_VALUE)
    )

Hi

I have a similar situation but it doesn't works

In a base i have column Year and Fiscal Year (Year<9,Year,Year+1)

and now i need to make a column which is Year or Fiscal year and use it instead of simple Year column on grpahs, slicers etc

in addition with this i made a table in query editor with 2 values and a slicer with them in report visualization

and i need when i filter one value the Year switchable column to be Year, or i select the other value and will be Year Fiscal

but it does't work, the calculated column is blank

Year = IF(
SELECTEDVALUE(Year_Type[Year_Type]) = "Calendar",
'Source'[YearCalendar],
IF(
SELECTEDVALUE(Year_Type[Year_Type]) = "Fiscal",
'Source'[YearFiscal],
BLANK()
)
)
 
any solution?
Thanks!
Cosmin

 

 

Hi

It works fine!

Thanks,

Cosmin

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.