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
Syndicate_Admin
Administrator
Administrator

Obtener recuento de filas según el período actual seleccionado por el usuario

Hola a todos

Lo que tengo que hacer es obtener un countrows para el período de informe actual y un countrows para todos los períodos de informe anteriores.

El resultado que quiero es:

Mes: Feb

Periodo actual: 2

Período anterior 10

Mes: Enero

Período actual: 4

Periodo anterior: 6

Estaba tratando de hacer una tabla filtrada con esta fórmula:

Recuento del período actual =
VAR maxdate = CALCULATE ( MAX('CalTable'[Date]), allselected(CalTable[Date]))
VAR mindate = CALCULAR ( MIN(CalTable[Date]),allselected(CalTable[Date]))
VAR filteredtable = filter ('Table1',[ReportingPeriod] <=maxdate && [ReportingPeriod]>=mindate)
return countrows(tabla1)
¿Hay alguna manera de hacer que esto funcione? ¡Gracias!

Current vs Prior Count Outcome.jpgTable - ReportingPeriod.jpg

1 ACCEPTED SOLUTION

Gracias @amitchandak . Ajusté un poco sus sugerencias y funcionó.


Recuento del período actual = CONTAR(Tabla1[RandomNumbers])
Todo el recuento del período anterior =
VAR _StartOfThisPeriod = FIRSTDATE('CalTable'[Fecha])
VAR _EndOfThisPeriod = LASTDATE('CalTable'[Fecha])
VAR _StartOfPriorPeriod = FIRSTDATE(ALL(CalTable[Date]))
VAR _EndOfPriorPeriod = _StartOfThisPeriod-1
DEVOLUCIÓN
CALCULATE(COUNT(Table1[RandomNumbers]), DATESBETWEEN('CalTable'[Date],_StartOfPriorPeriod,_EndOfPriorPeriod))

View solution in original post

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

@nikkirai , parece que tienes fecha y tabla de calendario (unido)

Pruebe medidas como

Ventas MTD = CALCULAR(SUMA(Ventas[Importe de ventas]),DATESMTD('Fecha'[Fecha]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))
último mes Ventas = CALCULAR(SUMA(Ventas[Importe de ventas]),mes anterior('Fecha'[Fecha]))
Ventas MTD = CALCULAR(SUMA(Ventas[Importe de ventas]),DATESMTD('Fecha'[Fecha]))
last MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-1,MONTH)))

MTD =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomes(_max,-1)+1 ,
devolución
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

Este mes =
var _max = eomonth(if(isfiltered('Date'),MAX( 'Date'[Date]) , today()),0)
var _min = eomes(_max,-1)+1 ,
devolución
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))

Gracias @amitchandak . Ajusté un poco sus sugerencias y funcionó.


Recuento del período actual = CONTAR(Tabla1[RandomNumbers])
Todo el recuento del período anterior =
VAR _StartOfThisPeriod = FIRSTDATE('CalTable'[Fecha])
VAR _EndOfThisPeriod = LASTDATE('CalTable'[Fecha])
VAR _StartOfPriorPeriod = FIRSTDATE(ALL(CalTable[Date]))
VAR _EndOfPriorPeriod = _StartOfThisPeriod-1
DEVOLUCIÓN
CALCULATE(COUNT(Table1[RandomNumbers]), DATESBETWEEN('CalTable'[Date],_StartOfPriorPeriod,_EndOfPriorPeriod))

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