Announcements
This site is in read only until July 22 as we migrate to a new platform; refer to this community post for more details.

Sum selected rows and columns

HELLO, I have this app with the table "Simulador"  the client chooses which format in this example is "Bilboard Desktop" in "Produto1" then choose which cities in this example is "Lisboa e Porto" in Região (enumlist) that is ref to the table "Inventario" and then needed to sum the inventory of all the chosen cities and only the chosen format in "Total impressões" .The data is in the "Inventario" table. I'm having trouble doing it in just one formula or just one table.

thanks for the help

Tiago_Pereira_0-1736357518173.pngTiago_Pereira_1-1736357561725.png

 

Solved Solved
0 5 210
1 ACCEPTED SOLUTION

Hi @Tiago_Pereira , data is in a format suitable for a spreadsheet, but not for a database. Ideally, you should have the initial two columns for Região and Produto, repeating the region for each new product. There is no need for the Visualizações Totais and % columns, as you can easily achieve this with a formula. The table would then have 3 columns: Região, Produto and Qtd. Thus, the expression could be: SUM(SELECT(Simulador[Qtd],AND(IN([Região],[_THISROW].[Região]),[Produto] = [_THISROW].[Produto]))).

Otherwise, you will need to create a SWITCH expression with one SUM/SELECT for each Produto.

View solution in original post

5 REPLIES 5

Hi, 
can you test

 

SUM(
  SELECT(
    Simulador[Produto1],
    AND(
      IN([Região],[Região]),
      [Produto1] = [Produto1]
    )
  )
)

 

 

 

Hi Jballester thanks for  the help, gives me the error The 'SUM' function requires a list of numeric inputs

 

Maybe if the table is inverted it will be easier? 

Tiago_Pereira_0-1736416854974.png

 

Hi @Tiago_Pereira , data is in a format suitable for a spreadsheet, but not for a database. Ideally, you should have the initial two columns for Região and Produto, repeating the region for each new product. There is no need for the Visualizações Totais and % columns, as you can easily achieve this with a formula. The table would then have 3 columns: Região, Produto and Qtd. Thus, the expression could be: SUM(SELECT(Simulador[Qtd],AND(IN([Região],[_THISROW].[Região]),[Produto] = [_THISROW].[Produto]))).

Otherwise, you will need to create a SWITCH expression with one SUM/SELECT for each Produto.

Thanks RBTAndrade
 🙏

 
Top Labels in this Space