March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
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:
Solved! Go to Solution.
Hi @MauricioSD ,
According to your new sample, here's my solution.
1.Create a new table, don't make relationship between the two tables.
Date = VALUES('Test'[PERIODO])
2.Create three measures.
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 ()
)
Get the correct result.
I attach my sample for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.
Hi @MauricioSD ,
Thanks for waiting patiently! I modify the formula like this:
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 ()
)
Get the correct result.
I attach my sample for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.
Your solution is correct, but i have a qestion,
why are there blank spaces in some months? :
The other question, the Marketshare (%) is correct, but the Ranking no:
The 1st is correct, the 2nd no:
Hi @MauricioSD ,
According to your description, here's my solution.
Create a calculated column.
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 ()
)
Create two measures.
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 ()
)
Get the result.
I attach my sample for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.
I try with your solution, but the calculated column "Total", not work
the correct solution should be:
But the power BI with your solution is:
I attach 2 files, the excel and the pbix with complete data base.
In adition, we can filter by column "market".
Hi @MauricioSD,
It's because in your original sample, there is only one value in the same date and same company, but in the new sample, there are many rows, they add up in the visual, it should then divide by the number of rows.
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 ()
)
Get the correct result.
I attach my sample for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.
Thank you for your help, the "total" is correct, but why there are many blank spaces? If it is the sum of the last 12 months
In adition, the Marketshare (%) work correctly, but the rank no:
Thanks !
Hi @MauricioSD ,
According to your new sample, here's my solution.
1.Create a new table, don't make relationship between the two tables.
Date = VALUES('Test'[PERIODO])
2.Create three measures.
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 ()
)
Get the correct result.
I attach my sample for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |