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
Hola,
Quisiera solicitar su apoyo para que me guíen en cómo agregar una línea adicional en la matriz de Power BI que se llame "Costa Comparable." Esta línea debería mostrar la suma de todos los puntos de venta (PDVs) dentro de la zona "Costa," excluyendo el PDV "DOM." La línea "Costa Total" debería mantenerse como el total de todos los PDVs en la zona Costa.
Además, necesitaría un total adicional que incluya el PDV "DOM" y otro que lo excluya, siendo este último llamado "Total Comparable."
Es importante mencionar que la clasificación de zonas proviene de una dimensión en la que los PDVs están agrupados por zona. Adjunto algunas imágenes para ilustrar cómo me gustaría que se vea el resultado en la matriz.
Agradezco mucho cualquier sugerencia o ajuste que me puedan brindar para implementar estas líneas en Power BI.
Solved! Go to Solution.
Hi @grgilardi ,
I've made a test for your reference:
1\I assume there is a table
2\Power Query
let
Source = Excel.Workbook(File.Contents("C:\Users\Bof\Desktop\Book1106.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"sucursal_id", Int64.Type}, {"zona", type text}, {"sucursal_abrev", type text}, {"value", Int64.Type}}),
// Filter out rows where sucursal_abrev is "DOM"
FilteredRows = Table.SelectRows(#"Changed Type", each [sucursal_abrev] <> "DOM"),
// Group by "zona" and calculate the sum of "value"
GroupedSummary = Table.Group(
FilteredRows,
{"zona"},
{{"value", each List.Sum([value]), type number},{"sucursal_abrev",each List.First([zona]) & " COMPARABLE" , type text }}
),
// Calculate the overall total for all non-DOM values
OverallTotalValue = List.Sum(FilteredRows[value]),
// Create an overall total row
OverallTotalRow = Table.FromRecords({
[sucursal_abrev = "TOTAL COMPARABLE", value = OverallTotalValue,zona="TOTAL COMPARABLE"]
}),
// Combine the original table with the summary table
CombinedTable = Table.Combine({#"Changed Type", GroupedSummary,OverallTotalRow}),
#"Changed Type1" = Table.TransformColumnTypes(CombinedTable,{{"value", type number}})
in
#"Changed Type1"
3\Add a measure
Custom Total =
If(ISINSCOPE(Sheet1[sucursal_abrev])||SELECTEDVALUE(Sheet1[zona])="TOTAL COMPARABLE",SUM(Sheet1[value]),CALCULATE(SUM(Sheet1[value]),NOT(ISBLANK(Sheet1[sucursal_id]))))
4\Add a matric visual
Best Regards,
Bof
Hi @grgilardi ,
I've made a test for your reference:
1\I assume there is a table
2\Power Query
let
Source = Excel.Workbook(File.Contents("C:\Users\Bof\Desktop\Book1106.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"sucursal_id", Int64.Type}, {"zona", type text}, {"sucursal_abrev", type text}, {"value", Int64.Type}}),
// Filter out rows where sucursal_abrev is "DOM"
FilteredRows = Table.SelectRows(#"Changed Type", each [sucursal_abrev] <> "DOM"),
// Group by "zona" and calculate the sum of "value"
GroupedSummary = Table.Group(
FilteredRows,
{"zona"},
{{"value", each List.Sum([value]), type number},{"sucursal_abrev",each List.First([zona]) & " COMPARABLE" , type text }}
),
// Calculate the overall total for all non-DOM values
OverallTotalValue = List.Sum(FilteredRows[value]),
// Create an overall total row
OverallTotalRow = Table.FromRecords({
[sucursal_abrev = "TOTAL COMPARABLE", value = OverallTotalValue,zona="TOTAL COMPARABLE"]
}),
// Combine the original table with the summary table
CombinedTable = Table.Combine({#"Changed Type", GroupedSummary,OverallTotalRow}),
#"Changed Type1" = Table.TransformColumnTypes(CombinedTable,{{"value", type number}})
in
#"Changed Type1"
3\Add a measure
Custom Total =
If(ISINSCOPE(Sheet1[sucursal_abrev])||SELECTEDVALUE(Sheet1[zona])="TOTAL COMPARABLE",SUM(Sheet1[value]),CALCULATE(SUM(Sheet1[value]),NOT(ISBLANK(Sheet1[sucursal_id]))))
4\Add a matric visual
Best Regards,
Bof
Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Need help uploading data? 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...
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
User | Count |
---|---|
20 | |
12 | |
10 | |
10 | |
7 |
User | Count |
---|---|
43 | |
26 | |
16 | |
16 | |
11 |