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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
gmasta1129
Resolver I
Resolver I

If Statement on a Measure

Hello, 

 

I created a measure that looks at the distinct count of a column with text.  

 

Measure = DISTINCTCOUNT(Table_Name[Investment_fund_name])

 

The output produced is a number. 

 

I would like to create an if statement on the measure above. 

If the output in the measure above is greater than 20, a value of 6 should pull in and if it is less than 20, then a value of 0 should pull in. 

 

If statements and switch are not producting the correct values. I am not sure what I am doing wrong. 

 

 

 

1 ACCEPTED SOLUTION
v-achippa
Community Support
Community Support

Hi @gmasta1129,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Based on the requirement, please use this below measure it will give either 6 or 0 based on the total number of distinct funds, regardless of the table or visual context where it is used:

 

Measure = VAR DistinctFundCount = CALCULATE(

    DISTINCTCOUNT(Table_Name[Investment_fund_name]),

    REMOVEFILTERS(Table_Name)

)

RETURN

IF(DistinctFundCount > 20, 6, 0)

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

 

Thanks and regards,

Anjan Kumar Chippa

View solution in original post

3 REPLIES 3
v-achippa
Community Support
Community Support

Hi @gmasta1129,

 

Thank you for reaching out to Microsoft Fabric Community.

 

Based on the requirement, please use this below measure it will give either 6 or 0 based on the total number of distinct funds, regardless of the table or visual context where it is used:

 

Measure = VAR DistinctFundCount = CALCULATE(

    DISTINCTCOUNT(Table_Name[Investment_fund_name]),

    REMOVEFILTERS(Table_Name)

)

RETURN

IF(DistinctFundCount > 20, 6, 0)

 

If this post helps, then please consider Accepting as solution to help the other members find it more quickly, don't forget to give a "Kudos" – I’d truly appreciate it! 

 

Thanks and regards,

Anjan Kumar Chippa

gmasta1129
Resolver I
Resolver I

Hello Akash, 

Unfortunately the formula did not work. When I place this measure into the table visual, it creates hundreds of rows rows and each row shows a value of 0.  

 

 

Akash_Varuna
Super User
Super User

Hi @gmasta1129 

Measure = 
IF(
    DISTINCTCOUNT(Table_Name[Investment_fund_name]) > 20, 
    6, 
    0
)

If this still doesn’t produce the expected result, double-check the calculation context (e.g., filters or relationships) in your report, as they can impact the measure's output.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.