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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
j_martinho
Helper I
Helper I

Sum total column values from the last 14 days

Hello!

 

I'm trying to create a new column (DAX or PowerQuery) so that it adds the value of the Cases column for the last 14 days.

The sum must take into account the CityCode. Thus, adding the last 14 days for each CityCode.

Can you help me?

 

Data example:

DateCasesCityCodeTotal Cases Last 14 days
10/08/202030125329737
09/08/202012335326725
08/08/202019215325492
07/08/202019035323571
06/08/202020345321668
05/08/202020425319634
04/08/202018805317592
03/08/202020165315712
02/08/202021065313696
01/08/202016305311590
31/07/20201850539960
30/07/20202100538110
29/07/20201616536010
28/07/20202246534394
27/07/20202148532148
10/08/202040121144737
09/08/202022331140725
08/08/202029211138492
07/08/202029031135571
06/08/202030341132668
05/08/202030421129634
04/08/202028801126592
03/08/202030161123712
02/08/202031061120696
01/08/202026301117590
31/07/202028501114960
30/07/202031001112110
29/07/20202616119010
28/07/20203246116394
27/07/20203148113148
1 ACCEPTED SOLUTION

@amitchandak I made two adjustments and solved it. Thank you!

 

 

Casos Ativos = 

sumx(
    filter(NOVO_PROTO,
            NOVO_PROTO[city_ibge_code] = earlier( NOVO_PROTO[city_ibge_code] )
             && NOVO_PROTO[Data] <= earlier( NOVO_PROTO[Data] )
             && NOVO_PROTO[Data] >= earlier( NOVO_PROTO[Data] )-13),

    NOVO_PROTO[Novos Confirmados])

 

View solution in original post

4 REPLIES 4
v-diye-msft
Community Support
Community Support

Hi @j_martinho 

 

Would you like to get the sum results of [Total Cases Last 14 days] by [Citycode]? You can try below calculated column:

Column = CALCULATE(SUM('Table (2)'[Total Cases Last 14 days]),FILTER(ALL('Table (2)'),[CityCode]=EARLIER('Table (2)'[CityCode])))

 

If not help. please kindly elaborate more.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.
amitchandak
Super User
Super User

@j_martinho , Try a new column

sumx(filter(Table, [CityCode] = earlier( [CityCode] ) && [CityCode] <= earlier( [Date] ) && [CityCode] >= earlier( [Date] )-14),[Total Cases])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak I made two adjustments and solved it. Thank you!

 

 

Casos Ativos = 

sumx(
    filter(NOVO_PROTO,
            NOVO_PROTO[city_ibge_code] = earlier( NOVO_PROTO[city_ibge_code] )
             && NOVO_PROTO[Data] <= earlier( NOVO_PROTO[Data] )
             && NOVO_PROTO[Data] >= earlier( NOVO_PROTO[Data] )-13),

    NOVO_PROTO[Novos Confirmados])

 

@amitchandak Thank you. But the column went blank.

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.

Top Solution Authors