Forum Discussion
How to compare in same table using slicer
I have this table:
| Producto | Categoria |
| a | H1 |
| a | H2 |
| a | H3 |
| b | H9 |
| b | H8 |
| b | H2 |
Then, I need create 2 slicer to compare.
The Slicer1 to select one product (example: product "a")
The Slicer2 to select other product (example: product "b")
The table of result is:
| Producto | Producto | Categoria |
| a | b | H9 |
| a | b | H8 |
Here I can see the difference between product "a" and product "b" is only on categories "H8" and "H9".
Sorry coz my english is very bad, thans to all for Help
I could solve it with this Measure:
Categoria_Exclusiva =
VAR Producto1 = SELECTEDVALUE(Tabla1[Producto])
VAR Producto2 = SELECTEDVALUE(Tabla2[Producto])VAR CategoriaProducto1 =
CALCULATETABLE(
FILTER(
VALUES(Tabla1[Categoria]),
LEFT(Tabla1[Categoria], 3) <> "ZRC" -- Excluir Categoria que comiencen con "ZRC"
),
Tabla1[Producto] = Producto1
)VAR CategoriaProducto2 =
CALCULATETABLE(
FILTER(
VALUES(Tabla2[Categoria]),
LEFT(Tabla2[Categoria], 3) <> "ZRC" -- Excluir Categoria que comiencen con "ZRC"
),
Tabla2[Producto] = Producto2
)VAR CategoriaExclusivosProducto1 =
EXCEPT(CategoriaProducto1, CategoriaProducto2)RETURN
IF(
SELECTEDVALUE(Tabla1[Categoria]) IN CategoriaExclusivosProducto1,
1, -- Es exclusivo
BLANK() -- No es exclusivo
)
3 Replies
- DanieleccHelper II
I could solve it with this Measure:
Categoria_Exclusiva =
VAR Producto1 = SELECTEDVALUE(Tabla1[Producto])
VAR Producto2 = SELECTEDVALUE(Tabla2[Producto])VAR CategoriaProducto1 =
CALCULATETABLE(
FILTER(
VALUES(Tabla1[Categoria]),
LEFT(Tabla1[Categoria], 3) <> "ZRC" -- Excluir Categoria que comiencen con "ZRC"
),
Tabla1[Producto] = Producto1
)VAR CategoriaProducto2 =
CALCULATETABLE(
FILTER(
VALUES(Tabla2[Categoria]),
LEFT(Tabla2[Categoria], 3) <> "ZRC" -- Excluir Categoria que comiencen con "ZRC"
),
Tabla2[Producto] = Producto2
)VAR CategoriaExclusivosProducto1 =
EXCEPT(CategoriaProducto1, CategoriaProducto2)RETURN
IF(
SELECTEDVALUE(Tabla1[Categoria]) IN CategoriaExclusivosProducto1,
1, -- Es exclusivo
BLANK() -- No es exclusivo
) - bhanu_gautamSuper User
Danielecc Try using
Go to the "Modeling" tab and select "New Table".
Create a new table with the same data as your original table.Table2 = Table1
Go to the "Model" view.
Create a relationship between Table1[Producto] and Table2[Producto].Add a slicer for Table1[Producto] and another slicer for Table2[Producto] to your report.
Create a new measure to identify the categories that are different between the two selected products.
DifferentCategories =
VAR SelectedProduct1 = SELECTEDVALUE(Table1[Producto])
VAR SelectedProduct2 = SELECTEDVALUE(Table2[Producto])
RETURN
CALCULATETABLE(
EXCEPT(
SELECTCOLUMNS(FILTER(Table1, Table1[Producto] = SelectedProduct1), "Categoria", Table1[Categoria]),
SELECTCOLUMNS(FILTER(Table2, Table2[Producto] = SelectedProduct2), "Categoria", Table2
Create a table visual:
Add a table visual to your report.
Use the Producto from Table1, Producto from Table2, and the Categoria from the measure DifferentCategories.- DanieleccHelper II
Hi bhanu_gautam , thanks for your reply.
I try your solution and I made the other table as you said and related product with product (that was a many to many relationship).
I made the measure and in the last line I had an error, but I solved with this change:
SELECTCOLUMNS(FILTER(Table2, Table2[Producto] = SelectedProduct2), "Categoria", Table2[Categoria])))
But when I made the Table visual with the products and this measure, doesn't work. The table visual was Empty.
Thanks a lot anyway