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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
JavierGomez
New Member

Distinctcount variable if

Buenas tardes,

Soy principiante en PBI, y hasta ahora, he podido ir solucionando todos los problemas que se me han ido presentando. Pero en esta ocasión, llevo 3 ó 4 semanas y no hay manera de encontrarla. 

Siento molestarles con esta cuestión, que me imagino que para ustedes será muy básica. Yo creo que puede ser hasta de concepto. 

En fin, el problema es el siguiente:

Tengo un distinctcount muy sencillo de una columna en una variable que, cuando lo pongo en una tarjeta o en una matriz, el resultado es bueno, pero cuando esa variable la uso en una sentencia if, el resultado no es bueno.

El if también es muy simple: Si el distinctcount es <=5, debe hacer A,y si no cumple, debe hacer B. Pero cuando uso un segmentador, sea cual sea el resultado que muestra la tarjeta o la matriz, el resultado de la instrucción if, siempre da el resultado A ,(aunque sea mayor a 5)

Seguro que la solución es simple

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @JavierGomez 


What do you mean by A and B?

Here's the sample:

Table:

vzhengdxumsft_0-1732590407712.png

The _Count measure is:

_Count = DISTINCTCOUNT('Table'[Values])

And it returens:

vzhengdxumsft_1-1732590482656.pngvzhengdxumsft_2-1732590487712.png

vzhengdxumsft_3-1732590492341.png

Then add a Measure:

Measure = IF([_Count]<=5,"A","B")

The result is as follow:

vzhengdxumsft_4-1732590525977.pngvzhengdxumsft_5-1732590533359.pngvzhengdxumsft_6-1732590538485.png

 

Best Regards

Zhengdong Xu
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

2 REPLIES 2
Anonymous
Not applicable

Hi @JavierGomez 


What do you mean by A and B?

Here's the sample:

Table:

vzhengdxumsft_0-1732590407712.png

The _Count measure is:

_Count = DISTINCTCOUNT('Table'[Values])

And it returens:

vzhengdxumsft_1-1732590482656.pngvzhengdxumsft_2-1732590487712.png

vzhengdxumsft_3-1732590492341.png

Then add a Measure:

Measure = IF([_Count]<=5,"A","B")

The result is as follow:

vzhengdxumsft_4-1732590525977.pngvzhengdxumsft_5-1732590533359.pngvzhengdxumsft_6-1732590538485.png

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.