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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Ffitzpatrick47
Helper II
Helper II

count rows vs has one value

Is there an update to this?

https://powerpivotpro.com/2011/03/the-magic-of-ifvalues/

 

 =IF(COUNTROWS(VALUES( <Your Column Here> ))=1, 
        IF(VALUES( <Your Column Here> ) =  <Test Value Here> , 
         <Result if True> , 
         <Result if False> ), 
   <Result for subtotals and grandtotals> )

 

That's more straight forward that this nested if?  I know there's a hasonevalue formula, but I don't know if it actually changes the structure of this.

1 ACCEPTED SOLUTION

Hi @Ffitzpatrick47,

 

In this scenario, there is no difference.

 

VALUES returns a one-column table that contains the distinct values from the specified table or column. HASONEVALUE returns TRUE when the context for columnName has been filtered down to one distinct value only. The usage of these two functions are different, but the returned result is the same. They can be used to check the numer of unique records of a column.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yulgu-msft
Employee
Employee

Hi @Ffitzpatrick47,

 

Based on my test, nesting HASONEVALUE inside IF function also worked. 

Measure = IF(HASONEVALUE(<Your Column Here>)=TRUE(), 
        IF(VALUES(<Your Column Here>)=<Test Value Here>, 
<Result if True>, <Result if False>), <Result for subtotals and grandtoals>)

If I have something misunderstood, please provide more description about your question.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

No, I just wanted to know if there was a difference between using the two.

Hi @Ffitzpatrick47,

 

In this scenario, there is no difference.

 

VALUES returns a one-column table that contains the distinct values from the specified table or column. HASONEVALUE returns TRUE when the context for columnName has been filtered down to one distinct value only. The usage of these two functions are different, but the returned result is the same. They can be used to check the numer of unique records of a column.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.