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
Nestor_Moreno
Frequent Visitor

How to Count value in a table with measure.

Hi im new in DAX and have the next situation, 

 

I have a table with 5 columns:

  • Nombre_Establecimiento
  • Ventas Periodo Anterior = 
    CALCULATE([Ventas_Periodo_Seleccionado];SAMEPERIODLASTYEAR('Calendar'[Date]))
  • Ventas Periodo Seleccionado = 
    CALCULATE(SUM(Empresario_Indicadores_Cuantita[Ventas]))
  • %_Crecimiento_Ventas = 
    (([Ventas_Periodo_Seleccionado]-[Ventas_Periodo_Anterior])/[Ventas_Periodo_Anterior])
  • Incremento_Ventas = 
    IF([%_Crecimiento_Ventas]>0;"SI";"NO")

The last 4 columns are measures.  This measures are showing sales of each business of this year and the last year.  With this information im calculating the % of increase in sales (%_Crecimiento_Ventas).  In the last column i put a conditional measure that evaluate if the % is greates than 0 then show "SI" if not show "NO"

 

I need to count on the number of business that increased sales, (it mean Incremento_Ventas = SI), and show this value in a card visualization.  for example in this table i need to show 4 business that increase sales. 

 

Incremento.PNG

 

Someone can help me with this trouble?

 

Thanks for your help

1 ACCEPTED SOLUTION
Anonymous
Not applicable

-- First, you should use DIVIDE instead of /

%_Crecimiento_Ventas = 
var __Ventas_Periodo_Seleccionado = [Ventas_Periodo_Seleccionado]
var __Ventas_Periodo_Anterior = [Ventas_Periodo_Anterior]
return
	divide(
		__Ventas_Periodo_Seleccionado - __Ventas_Periodo_Anterior,
		__Ventas_Periodo_Anterior
	)

-- And this is (most likely) what you need:

[# Businesses With SI] =
var __businesses = VALUES( Establecimientos[Nombre_Establecimiento] )
var __businessesWithSI =
	filter(
		__businesses,
		[Incremento_Ventas] = "SI"
	)
var __countOfbusinessesWithSI =
	countrows( __businessesWithSI )
return
	__countOfbusinessesWithSI

Best

Darek

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

-- First, you should use DIVIDE instead of /

%_Crecimiento_Ventas = 
var __Ventas_Periodo_Seleccionado = [Ventas_Periodo_Seleccionado]
var __Ventas_Periodo_Anterior = [Ventas_Periodo_Anterior]
return
	divide(
		__Ventas_Periodo_Seleccionado - __Ventas_Periodo_Anterior,
		__Ventas_Periodo_Anterior
	)

-- And this is (most likely) what you need:

[# Businesses With SI] =
var __businesses = VALUES( Establecimientos[Nombre_Establecimiento] )
var __businessesWithSI =
	filter(
		__businesses,
		[Incremento_Ventas] = "SI"
	)
var __countOfbusinessesWithSI =
	countrows( __businessesWithSI )
return
	__countOfbusinessesWithSI

Best

Darek

Thanks Darlove.

 

It worked perfect!!!

 

Regards

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.

Top Solution Authors