Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
julianoguerra
Contributor II
Contributor II

SOMASES

Olá, 

Preciso criar um novo campo a partir de uma somases, que respeite o Cod Centro e o mês, mas sem especificar entre ' ' os valores.

 

Captura de tela 2024-08-07 174349.png

 

Obrigado.

 

 

 

 

2 Replies
MatheusC
Specialist
Specialist

@julianoguerra 
Experimente utilizar o qualificador total, você pode estar definindo as dimensões a qual quer totalizar entre os sinais de menor e maior  <  >.

Então seria algo assim:

sum(total<[Mês/Ano],[Cod Centro]>[Qtde Total])

- Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
cris458carlo
Contributor II
Contributor II

Hello,

 

You want to create a new field in your data based on a sum of cases, while grouping by Center Code and month, but without using single quotes for values. Assuming you're working with SQL or a similar query language, here's a general approach to achieve that:

SQL Approach
If you're using SQL, you can achieve this with a GROUP BY clause and SUM function. Here's a basic example: SELECT
CenterCode,
MONTH(DateColumn) AS Month,
SUM(Cases) AS TotalCases
FROM
YourTable
GROUP BY
CenterCode,
MONTH(DateColumn); 

In Other Query Languages
For languages or tools like DAX in Power BI, or pandas in Python, the approach will vary slightly. Here’s how you might do it:

DAX (Power BI) NewField =
SUMX(
FILTER(
YourTable,
YourTable[CenterCode] = EARLIER(YourTable[CenterCode]) &&
MONTH(YourTable[DateColumn]) = EARLIER(MONTH(YourTable[DateColumn]))
),
YourTable[Cases]
) Pandas (Python) 

import pandas as pd

# Assuming df is your DataFrame
df['Month'] = df['DateColumn'].dt.month
result = df.groupby(['CenterCode', 'Month'])['Cases'].sum().reset_index()
result.rename(columns={'Cases': 'TotalCases'}, inplace=True) 

 

Hope that helps!

vanilla gift card balance