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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Sum over partition by order by in DAX

Hey guys,

 

I'm struggling to think of a way to solve my problem in DAX. In SQL I'd use sum over partition by order by, but in DAX I dont know what the equivalent is.

 

The dataset is like this:

dayprogram weekSales
01/01/2017AW01400
02/01/2017AW01450
03/01/2017AW01500
04/01/2017AW01600
05/01/2017AW01450
06/01/2017AW01550
07/01/2017AW01560
08/01/2017AW02400
09/01/2017AW02450
10/01/2017AW02500
11/01/2017AW02600
12/01/2017AW02450
13/01/2017AW02550
14/01/2017AW02560

 

What I want is a fourth column (measure/column?) that gives me the cumulative sum of these values, but partitioned by program week and ordered by date.

 

The resulting table should look like this:

 

dayprogram weekSalesCumulative Weekly
01/01/2017AW01400400
02/01/2017AW01450850
03/01/2017AW015001350
04/01/2017AW016001950
05/01/2017AW014502400
06/01/2017AW015502950
07/01/2017AW015603510
08/01/2017AW02200200
09/01/2017AW02450650
10/01/2017AW025001150
11/01/2017AW026001750
12/01/2017AW024502200
13/01/2017AW025502750
14/01/2017AW025603310

 

Thanks for the help guys!

 

Jaap

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@Anonymous

 

Hi, Create a Calculated Column:

 

CumulativeWeekly =
CALCULATE (
    SUM ( Table1[Sales] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[program week] ),
        Table1[day] <= EARLIER ( Table1[day] )
    )
)

Let me know if you need more help

 

Regards

 

Victor

Lima - Peru




Lima - Peru

View solution in original post

7 REPLIES 7
Vvelarde
Community Champion
Community Champion

@Anonymous

 

Hi, Create a Calculated Column:

 

CumulativeWeekly =
CALCULATE (
    SUM ( Table1[Sales] ),
    FILTER (
        ALLEXCEPT ( Table1, Table1[program week] ),
        Table1[day] <= EARLIER ( Table1[day] )
    )
)

Let me know if you need more help

 

Regards

 

Victor

Lima - Peru




Lima - Peru
Anonymous
Not applicable

@Vvelarde Hola Victor, tengo un problema similar, agradecería la ayuda 🙂

Tengo un campo llamado ID, el cual corresponde a los ID de cada negocio y un campo fecha o mes.  Necesito crear un contador por ID y ordenarlo por fecha. Esto sería un ejemplo de lo mencionado:

 

IDmesValorContador
111311
111212
111113
222314
222413
222512
222611
33112
33211

@Anonymous

 

Hola, Según veo tu contador es por ID y la Fecha de Mayor a Menor. Correcto?

 

Te puedo preguntar cual es el sentido de lo que buscas.

 

Saludos




Lima - Peru
Anonymous
Not applicable

@Vvelarde Claro, debo dejar los ID más actuales.

 

Esto lo necesito para poder reflejar esta información en una pestaña y filtrar por los que tienen el contador 1. De esta manera dejaría los más actuales y el resto no serán considerados.

 

Gracias!

@Anonymous

 

Try with this

 

Orden =
COUNTROWS (
    FILTER (
        Table1;
        Table1[ID] = EARLIER ( Table1[ID] )
            && Table1[mes] >= EARLIER ( Table1[mes] )
    )
)

 

Spoiler
 

 




Lima - Peru
Anonymous
Not applicable

Hi Victor,

 

Here data is in ascending order by date, can we achieve the same if data unoriented.

I mean without using ordered data. I am struggling for the same.

 

Regards,

Uma

Anonymous
Not applicable

My hero lives in Lima, and his name is Victor!

 

Do you happen to know any sources that kind of list SQL equivalents of functions in DAX? I'm still strugging to think the DAX way instead of the more straightforward SQL way....

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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