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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
andreaturri27
Helper I
Helper I

subtracion row custom column

Hi community, 

 

i have this situation

 

Immagine 2022-09-09 143207.jpg

i would obtain this result it's possibile? only custom column

cattura2.jpg

thank you

Regards 

 

Andrea 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @andreaturri27 ,

Here are the steps you can follow:

1. In Power query. Add Column – Index Column – From 1.

vyangliumsft_0-1663122199348.png

2. Create calculated column.

min =
var _min=MINX(FILTER(ALL('Table'),'Table'[id_progetto]=EARLIER('Table'[id_progetto])),[Index])
return
IF(
    'Table'[Index]=_min ,
    [Moltiplicazione],
    BLANK())
Sottazione =
CALCULATE(
    SUM('Table'[min]) - SUM('Table'[h_Prog]),
    FILTER(ALL('Table'),'Table'[id_progetto]=EARLIER('Table'[id_progetto])&& 'Table'[Index]<=EARLIER('Table'[Index])))

3. Result:

vyangliumsft_1-1663122199351.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi  @andreaturri27 ,

Here are the steps you can follow:

1. In Power query. Add Column – Index Column – From 1.

vyangliumsft_0-1663122199348.png

2. Create calculated column.

min =
var _min=MINX(FILTER(ALL('Table'),'Table'[id_progetto]=EARLIER('Table'[id_progetto])),[Index])
return
IF(
    'Table'[Index]=_min ,
    [Moltiplicazione],
    BLANK())
Sottazione =
CALCULATE(
    SUM('Table'[min]) - SUM('Table'[h_Prog]),
    FILTER(ALL('Table'),'Table'[id_progetto]=EARLIER('Table'[id_progetto])&& 'Table'[Index]<=EARLIER('Table'[Index])))

3. Result:

vyangliumsft_1-1663122199351.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

andreaturri27
Helper I
Helper I

hi @PabloDeheza  the solution dosn't work..

 

Pippo2 =
SUMX (
    FILTER (
        Stampa_Ostinelli_PROG,
        EARLIER ( Stampa_Ostinelli_PROG[Id_progetto]) = Stampa_Ostinelli_PROG[Id_progetto]
            && EARLIER ( Stampa_Ostinelli_PROG[Indice]  ) >= Stampa_Ostinelli_PROG[Indice]
    ),
   Stampa_Ostinelli_PROG[h_prog]
)
error is
 
EARLIER / EARLIEST refers to a previous row context that does not exist.
 
PabloDeheza
Solution Sage
Solution Sage

Hi there!

Clould you please describe what the logic should be?

Thanks!

 

3000 - 240 = 2760

2760-60 = 2700

2700-480=2220

group by id_progetto

I solution could be this:
Go to Power Query and add an index column starting from 1 like this:

PabloDeheza_0-1662730982381.png

Then go create a new calculated column in DAX with the following code:

SUMX (
    FILTER (
        YourTable,
        EARLIER ( YourTable[Id_progetto] ) = YourTable[Id_progetto]
            && EARLIER ( YourTable[Index] ) >= YourTable[Index]
    ),
    YourTable[h_prog]
)

Then add a final column like this one:

Final Column = YourTable[Moltiplicazione] -  YourTable[PreviousCreatedColumn]

Let me know if that helps!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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
Top Kudoed Authors