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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Syndicate_Admin
Administrator
Administrator

Recuento diario entre fechas para cada región

Hola

Tengo una tabla que abarca varios meses que muestra el acumulado para cada distrito a lo largo de ese mes.

Necesito una columna calculada que calcule el recuento diario para cada distrito.

Una vez que termina el mes, debe reiniciarse. Entonces, el 1 de julio, el recuento diario es esencialmente la cantidad acumulada, ya que es el día 1.

Ejemplo de lo que estoy buscando:

FECHADISTRITOACUMULATIVORECUENTO DIARIO
6/15/2022Distrito 1193611466
6/15/2022Distrito 210328876
6/15/2022Distrito 37229735
6/16/2022Distrito 1205211160
6/16/2022Distrito 210943615
6/16/2022Distrito 37724495

... (fechas restantes de junio)

FECHADISTRITOACUMULATIVORECUENTO DIARIO
7/01/2022Distrito 115011501
7/01/2022Distrito 2718718
7/01/2022Distrito 3505505
7/02/2022Distrito 128081307
7/02/2022Distrito 21252 534
7/02/2022Distrito 3703 198

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

@mskarasha,

Pruebe esta columna calculada:

DAILY COUNT = 
VAR vDate = Table1[DATE]
VAR vPrevDate =
    CALCULATE (
        MAX ( Table1[DATE] ),
        ALLEXCEPT ( Table1, Table1[DISTRICT] ),
        Table1[DATE] < vDate
    )
VAR vPrevAmount =
    CALCULATE (
        SUM ( Table1[CUMULATIVE] ),
        ALLEXCEPT ( Table1, Table1[DISTRICT] ),
        Table1[DATE] = vPrevDate
    )
VAR vResult =
    IF (
        DAY ( Table1[DATE] ) = 1,
        Table1[CUMULATIVE],
        Table1[CUMULATIVE] - vPrevAmount
    )
RETURN
    vResult

DataInsights_0-1660222219065.png

Esto funcionó perfectamente, ¡gracias!

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors