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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
adoster
Resolver I
Resolver I

Adding an IF statement to existing Measure to Filter only on 1 Row of results

Hello,

Apologies that I don't have good sample data for this question. If this doesn't make sense I'll try to simplify.

 

I would like to add an IF statement to filter on an existing Measure so that only 1 row in my visual is filtered

 

Example: I need to add an IF FILTER only on the Vascular Surgery Row

 201920202021
VAD2060100
Heart3070101
Valve4080102
Vascular Surgery5090103

 

Here is the Existing Measure: 

CountByRank =

     VAR res =
          CALCULATE (
               COUNT ( 'All Data'[Procedure_Desc] ),
               FILTER ( 'All Data', 'All Data'[LowestRank] = 1 ),
               ALLEXCEPT ( 'All Data', 'All Data'[Service Date] )
)
RETURN
IF ( ISBLANK ( res ), 0, res )

 

 

Here is the IF statement I need to add to the above measure.

 

IF ('All Data', 'All Data'[Provider Groups] = "Vascular Surgery")
     FILTER('ProcedureList', 'ProcedureList'[Service] = "Vascular Surgery")

 

Not sure how/where this new statement should fit in with the original.

 

Thanks for any assistance!

1 ACCEPTED SOLUTION
adoster
Resolver I
Resolver I

I found a solution to this today

1. Created a Metric to Calculate everything exept Vascular Surgery

2. Created a Metric to Calculate Vascular Surgery Filtering only by the Provider group

3. Created a Metric to Total 1 & 2

View solution in original post

2 REPLIES 2
adoster
Resolver I
Resolver I

I found a solution to this today

1. Created a Metric to Calculate everything exept Vascular Surgery

2. Created a Metric to Calculate Vascular Surgery Filtering only by the Provider group

3. Created a Metric to Total 1 & 2

Russell-PBI
Resolver II
Resolver II

Hi @adoster, it depends on what your model looks like as I can see you have at least two tables (All Data and ProcedureList).

 

It might be possible to solve it with a calculated column. Your IF statement isn't valid, but it looks like you want to exclude all other values except the "Vascular Surgery" service for the "Vascular Surgery" provider group only? If so, you may be able to use a calculated column like this:

Include in Count Flag =
IF(
'All Data'[Provider Groups] = "Vascular Surgery"
&& RELATED('ProcedureList'[Service]) = "Vascular Surgery"
|| NOT 'All Data'[Provider Groups] = "Vascular Surgery"
, 1
, 0
)
You could then use this as a filter on your visual, page or report; or reference it in your existing measure:
CountByRank =
     VAR res =
          CALCULATE (
               COUNT ( 'All Data'[Procedure_Desc] ),
               FILTER ( 'All Data', 'All Data'[LowestRank] = 1 ),
               ALLEXCEPT ( 'All Data', 'All Data'[Service Date] ),
'All Data'[Include in Count Flag] = 1
)
RETURN
IF ( ISBLANK ( res ), 0, res )
This may only work if your ProcedureList table is the 'one' side of a one:many relationship.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors