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

View all the Fabric Data Days sessions on demand. View schedule

Reply
grgilardi
Frequent Visitor

Configuración de Líneas de Comparación en Matriz"

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.

1111.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @grgilardi ,

 

I've made a test for your reference:

1\I assume there is a table

vbofengmsft_0-1730857998381.png

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"

vbofengmsft_1-1730858053366.png

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

vbofengmsft_2-1730858132747.png

 

Best Regards,

Bof

 

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @grgilardi ,

 

I've made a test for your reference:

1\I assume there is a table

vbofengmsft_0-1730857998381.png

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"

vbofengmsft_1-1730858053366.png

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

vbofengmsft_2-1730858132747.png

 

Best Regards,

Bof

 

 

lbendlin
Super User
Super User

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...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.