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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Syndicate_Admin
Administrator
Administrator

Cuota de mercado acumulada a 12 meses móviles

Estimados, buenos días.

Primero que todo, agradecer por su continua ayuda.

Necesito hacer un Marketshare de varias compañías y también de varios otros segmentadores.

Tengo una tabla histórica con el dato de la fecha-monto-empresa esas serían las 3 principales columnas.

Y el marketshare se calcula como la suma del monto de los ultimos 12 meses.

Entonces el monto total de 1 empresa de diciembre-2021 es la suma de enero2021-diciembre2021.

El marketshare es el % de participación del mercado de cada empresa, que entonces el (monto de cada empresa)/(monto total)

Y por ultimo el ranking en el que se ubica según % del Marketshare.

Hoy he logrado obtener el monto acumulado de los 12 meses moviles con la formula:

Donde Total =
Dónde last_date = MÁXIMO('Calendario'[Fecha])
devolución
CALCULAR(SUMA(Cuota de mercado[CIF Total]),
DATESINPERIOD('Calendario'[Fecha],last_date,-12,MES))
Pero no puedo obtener el % Marketshare y tampoco el Ranking de cada empresa que pueda colocarlo en una tabla, etc.
Favor su ayuda, adjunto un excel de ejemplo como debería quedar.

MauricioSD_0-1646750941478.png

1 ACCEPTED SOLUTION

@MauricioSD ,

De acuerdo con su nueva muestra, aquí está mi solución.

1.Cree una nueva tabla, no haga una relación entre las dos tablas.

Date = VALUES('Test'[PERIODO])

2.Crear tres medidas.

Total =
IF (
    DATEDIFF (
        MINX ( ALL ( Test ), Test[Month] ),
        MAXX (
            FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
            Test[Month]
        ),
        MONTH
    ) >= 11,
    CALCULATE (
        SUM ( Test[CIF Total] ),
        DATESINPERIOD (
            Test[Month],
            MAXX (
                FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
                Test[Month]
            ),
            - 12,
            MONTH
        ),
        ALLEXCEPT ( Test, Test[GRUPO MARCA] )
    ),
    BLANK ()
)
Marketshare (%) Test =
VAR _SUM =
    CALCULATE (
        SUM ( Test[CIF Total] ),
        DATESINPERIOD (
            Test[Date],
            MAXX (
                FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
                Test[Date]
            ),
            - 12,
            MONTH
        ),
        ALL ( Test )
    )
VAR _D =
    DIVIDE ( [Total], _SUM )
RETURN
    _D
Ranking =
IF (
    DATEDIFF (
        MINX ( ALL ( Test ), Test[Month] ),
        MAXX (
            FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
            Test[Month]
        ),
        MONTH
    ) >= 11,
    RANKX (
        FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
        CALCULATE ( [Marketshare (%) Test] ),
        ,
        DESC,
        DENSE
    ),
    BLANK ()
)

Obtenga el resultado correcto.

vkalyjmsft_0-1647598659149.png

Adjunto mi muestra como referencia.

Saludos
Equipo de apoyo a la comunidad _ kalyj

Si esta publicación ayuda, por favor considereAceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

View solution in original post

12 REPLIES 12
Syndicate_Admin
Administrator
Administrator

@v-kalyj-msft

Por favor, su ayuda, para poder aplicar filtros en los datos

@MauricioSD ,

¡Gracias por esperar pacientemente! Modifico la fórmula así:

Total =
IF (
    DATEDIFF (
        MINX ( ALL ( Test ), Test[Month] ),
        MAXX (
            FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
            Test[Month]
        ),
        MONTH
    ) >= 11,
    CALCULATE (
        SUM ( Test[CIF Total] ),
        DATESINPERIOD (
            Test[Month],
            MAXX (
                FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
                Test[Month]
            ),
            - 12,
            MONTH
        ),
        ALLEXCEPT ( Test, Test[GRUPO MARCA], Test[Market] )
    ),
    BLANK ()
)
Marketshare (%) Test =
VAR _SUM =
    CALCULATE (
        SUM ( Test[CIF Total] ),
        DATESINPERIOD (
            Test[Date],
            MAXX (
                FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
                Test[Date]
            ),
            - 12,
            MONTH
        ),
        ALLEXCEPT ( Test, 'Test'[Market] )
    )
VAR _D =
    DIVIDE ( [Total], _SUM )
RETURN
    _D
Ranking =
IF (
    DATEDIFF (
        MINX ( ALL ( Test ), Test[Month] ),
        MAXX (
            FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
            Test[Month]
        ),
        MONTH
    ) >= 11,
    RANKX (
        FILTER (
            ALLEXCEPT ( 'Test', 'Test'[Market] ),
            'Test'[PERIODO] = MAX ( 'Date'[PERIODO] )
        ),
        CALCULATE ( [Marketshare (%) Test] ),
        ,
        DESC,
        DENSE
    ),
    BLANK ()
)

Obtenga el resultado correcto.

vkalyjmsft_0-1648005029144.png

Adjunto mi muestra como referencia.

Saludos
Equipo de apoyo a la comunidad _ kalyj

Si esta publicación ayuda, por favor considereAceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Syndicate_Admin
Administrator
Administrator

Hi @v-kalyj-msft

Su solución es correcta, pero tengo una pregunta,

¿por qué hay espacios en blanco en algunos meses? :

MauricioSD_0-1647353084831.png

La otra pregunta, la cuota de mercado (%) es correcta, pero el Ranking no:

El 1º es correcto, el 2º no:

MauricioSD_1-1647353191280.png

Syndicate_Admin
Administrator
Administrator

Hola @MauricioSD ,

De acuerdo con su descripción, aquí está mi solución.

Cree una columna calculada.

Total =
IF (
    DATEDIFF (
        MINX ( ALL ( 'Marketshare' ), 'Marketshare'[Date] ),
        'Marketshare'[Date],
        MONTH
    ) >= 11,
    CALCULATE (
        SUM ( Marketshare[CIF Total] ),
        DATESINPERIOD ( 'Marketshare'[Date], 'Marketshare'[Date], - 12, MONTH ),
        ALLEXCEPT ( 'Marketshare', 'Marketshare'[Company] )
    ),
    BLANK ()
)

Crea dos medidas.

MarketShare  (%) =
VAR _SUM =
    CALCULATE (
        SUM ( Marketshare[CIF Total] ),
        DATESINPERIOD ( 'Marketshare'[Date], MAX ( 'Marketshare'[Date] ), - 12, MONTH ),
        ALL ( Marketshare )
    )
VAR _D =
    DIVIDE ( MAX ( 'Marketshare'[Total] ), _SUM )
RETURN
    _D
Ranking =
IF (
    DATEDIFF (
        MINX ( ALL ( 'Marketshare' ), 'Marketshare'[Date] ),
        MAX ( 'Marketshare'[Date] ),
        MONTH
    ) >= 11,
    RANKX (
        FILTER (
            ALL ( 'Marketshare' ),
            'Marketshare'[Date] = MAX ( 'Marketshare'[Date] )
        ),
        CALCULATE ( SUM ( 'Marketshare'[Total] ) ),
        ,
        DESC,
        DENSE
    ),
    BLANK ()
)

Obtén el resultado.

vkalyjmsft_0-1646988025968.png

Adjunto mi muestra como referencia.

Saludos
Equipo de apoyo a la comunidad _ kalyj

Si esta publicación ayuda, por favor considereAceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Hi @v-kalyj-msft

Lo intento con su solución, pero la columna calculada "Total", no funciona

la solución correcta debe ser:

MauricioSD_0-1647025453032.png

Pero el poder de BI con su solución es:

MauricioSD_1-1647025526655.png

Adjunto 2 archivos, el excel y el pbix con base de datos completa.

Además, podemos filtrar por columna "mercado".

Adjunto

@MauricioSD,

Es porque en su muestra original, solo hay un valor en la misma fecha y la misma compañía, pero en la nueva muestra, hay muchas filas, se suman en el visual, luego debe dividirse por el número de filas.

vkalyjmsft_0-1647324020850.png

Total =
IF (
    DATEDIFF ( MINX ( ALL ( Test ), Test[Month] ), Test[Month], MONTH ) >= 11,
    CALCULATE (
        SUM ( Test[CIF Total] )
            / COUNTROWS (
                FILTER (
                    ALL ( 'Test' ),
                    'Test'[GRUPO MARCA] = MAX ( 'Test'[GRUPO MARCA] )
                        && 'Test'[Month] = MAX ( 'Test'[Month] )
                )
            ),
        DATESINPERIOD ( Test[Month], Test[Month], - 12, MONTH ),
        ALLEXCEPT ( Test, Test[GRUPO MARCA] )
    ),
    BLANK ()
)

Obtenga el resultado correcto.

vkalyjmsft_1-1647324391846.png

Adjunto mi muestra como referencia.

Saludos
Equipo de apoyo a la comunidad _ kalyj

Si esta publicación ayuda, por favor considereAceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Hi @v-kalyj-msft

Gracias por su ayuda, el "total" es correcto, pero ¿por qué hay muchos espacios en blanco? Si es la suma de los últimos 12 meses

MauricioSD_0-1647440519767.png

Además, la cuota de mercado (%) funciona correctamente, pero el rango no:

MauricioSD_1-1647440618789.png

¡Gracias!

@MauricioSD ,

De acuerdo con su nueva muestra, aquí está mi solución.

1.Cree una nueva tabla, no haga una relación entre las dos tablas.

Date = VALUES('Test'[PERIODO])

2.Crear tres medidas.

Total =
IF (
    DATEDIFF (
        MINX ( ALL ( Test ), Test[Month] ),
        MAXX (
            FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
            Test[Month]
        ),
        MONTH
    ) >= 11,
    CALCULATE (
        SUM ( Test[CIF Total] ),
        DATESINPERIOD (
            Test[Month],
            MAXX (
                FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
                Test[Month]
            ),
            - 12,
            MONTH
        ),
        ALLEXCEPT ( Test, Test[GRUPO MARCA] )
    ),
    BLANK ()
)
Marketshare (%) Test =
VAR _SUM =
    CALCULATE (
        SUM ( Test[CIF Total] ),
        DATESINPERIOD (
            Test[Date],
            MAXX (
                FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
                Test[Date]
            ),
            - 12,
            MONTH
        ),
        ALL ( Test )
    )
VAR _D =
    DIVIDE ( [Total], _SUM )
RETURN
    _D
Ranking =
IF (
    DATEDIFF (
        MINX ( ALL ( Test ), Test[Month] ),
        MAXX (
            FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
            Test[Month]
        ),
        MONTH
    ) >= 11,
    RANKX (
        FILTER ( ALL ( 'Test' ), 'Test'[PERIODO] = MAX ( 'Date'[PERIODO] ) ),
        CALCULATE ( [Marketshare (%) Test] ),
        ,
        DESC,
        DENSE
    ),
    BLANK ()
)

Obtenga el resultado correcto.

vkalyjmsft_0-1647598659149.png

Adjunto mi muestra como referencia.

Saludos
Equipo de apoyo a la comunidad _ kalyj

Si esta publicación ayuda, por favor considereAceptarlo como la solución para ayudar a los otros miembros a encontrarlo más rápidamente.

Estimado @v-kalyj-msft

Cuando filtro por "Mercado", los números no tienen variación, por ejemplo:

MauricioSD_0-1647614534762.png

Gracias @v-kalyj-msft la solución funciona correctamente

Hi @v-kalyj-msft

Lo intento pero la columna calculada "total" no funciona correctamente.

Por ejemplo, sor la Compañía 1, la suma de los últimos 12 meses shpuld ser: 5,240,455,327 y el "Total" muestra: 2,704,074,948,897 es un error.

Correcto:

MauricioSD_0-1647018658250.png

Incorrecto en PowerBI:

MauricioSD_1-1647018688818.png

¡Adjunta el excel y el power bi para tu ayuda!

Además, podemos filtrar por columna "mercado", está en el pbix attach.

Muchas gracias

Archivos

Syndicate_Admin
Administrator
Administrator

Adjunto archivo excel correspondiente.

Sobresalir

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors