- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Contar valores unicos de una columna en dos años consecutivos
Hola
Tengo una tabla central donde se encuentran las ventas de los productos de varios años (hechos), relacionado a la tabla calendario
La siguiente imagen muestra la cantidad de productos (id_productos) unicos vendidos en cada año.
Lo que se desea es que en el año 2023 tenga la cantidad de productos unicos vendidos en el 2023 y 2022, en el año 2022 tenga la cantidad de productos unicos vendidos en el 2022 y 2021, y asi sucesivamente,
He intentado varias formulas pero no logro tener los datos correctos.
Lo ultimo que intente es esto pero no funciona
tmp_cantempexp =
He usado esa formula pero no me obtiene lo que necesito, alguna idea?
Gracias.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @Glenan ,
I created some data:
Here are the steps you can follow:
1. Create measure.
Measure =
var _table1=
SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])),"1",[Product_ID])
var _table2=
SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[Year]=MAX('Table'[Year])-1),"2",[Product_ID])
var _table3=
UNION(
_table1,_table2)
var _table4=
SUMMARIZE(_table3,[1])
return
COUNTX(
_table4,[1])
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ahi alguna data de ejemplo, que muestra en escencia lo que necesito, lo vuelvo a explicar por si no se me entendió.
Contar los productos unicos que se vendieron en dos años consecutivos, por ejemplo si el producto ABC se vendio en el 2022 y 2023 (la cantidad veces que sea que se haya vendido) se cuenta como 1 y se muestra en el ultimo periodo tal como se muestra en la tabla RESULTS
Calendar Table (La relación de calendario y fact table obviamente es uno a muchos)
ID_PERIODO | PERIODO |
100 | 2020 |
101 | 2021 |
102 | 2022 |
103 | 2023 |
FACT TABLE
IDVENTA | ID_PRODUCTO | ID_PERIODO |
1 | 100000A | 102 |
2 | 100000B | 102 |
3 | 100000F | 101 |
4 | 10000GT | 101 |
5 | 100000A | 102 |
3 | 100000A | 103 |
4 | 100000B | 103 |
1 | 100000F | 102 |
5 | 10000GT | 103 |
RESULTS
PERIODO | TOTAL |
2020 | 0 |
2021 | 0 |
2022 | 1 |
2023 | 2 |
En el periodo 2023 se cuentan los productos 100000A, 100000B = 2, ya que ambos se vendieron el 2022 y 2023.
En el periodo 2022 solo se cuenta el producto 100000F = 1 ya que se vendio el 2022 y 2021.
Espero su ayuda, gracias.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Ibendlin
With some adjustements it works perfect!!!
Best Regards.
Glenan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information or anything not related to the issue or question.
If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...
