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
edubcardoso
Advocate I
Advocate I

Subtract the value from 1st step when its not blank

Hello everyone!

I'm struggling with this calculation.
My goal is to get the sum off the value, but it has a twist:

1) I want to subtract the 1s step to the next one with a value, but in the same project.

For the project 17651, i want to subtract the 1st step in the 3rd(because it is the next with a value, 2nd step is blank)
For the project 45521, it should subtract step 1 to step 2.

Project |Step |        |     Value     |      Goal
176511 13 186,29 €13186,29
176512  0
176513 100 062,77 €100062,77-13186,29
199291  0
199292 16 076,69 €16076,69
199293 39 756,08 €39756,08
199294  0
199295 37 660,47 €37660,47
455211 10 047,6 €10047,60
455212 12 196,3 €12196,30-10047,60
455213 16 795,44 €16795,44
455214 23 589,9 €23589,90

 

Can you help me, please?

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1674744145816.png

 

Value measure: = 
SUM( Data[Value] )

 

 

Goal measure: =
VAR _currentproject =
    MAX ( Data[Project] )
VAR _minstepaftersteptwo =
    MINX (
        FILTER (
            ALL ( Data ),
            Data[Project] = _currentproject
                && Data[Step] > 1
                && Data[Value] <> BLANK ()
        ),
        Data[Step]
    )
VAR _steponevalue =
    CALCULATE ( [Value measure:], Data[Step] = 1 )
RETURN
    IF (
        HASONEVALUE ( Data[Project] ),
        SWITCH (
            TRUE (),
            [Value measure:] = BLANK (), 0,
            MAX ( Data[Step] ) = 1, [Value measure:],
            MAX ( Data[Step] ) = _minstepaftersteptwo, [Value measure:] - _steponevalue,
            [Value measure:]
        )
    )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1674744145816.png

 

Value measure: = 
SUM( Data[Value] )

 

 

Goal measure: =
VAR _currentproject =
    MAX ( Data[Project] )
VAR _minstepaftersteptwo =
    MINX (
        FILTER (
            ALL ( Data ),
            Data[Project] = _currentproject
                && Data[Step] > 1
                && Data[Value] <> BLANK ()
        ),
        Data[Step]
    )
VAR _steponevalue =
    CALCULATE ( [Value measure:], Data[Step] = 1 )
RETURN
    IF (
        HASONEVALUE ( Data[Project] ),
        SWITCH (
            TRUE (),
            [Value measure:] = BLANK (), 0,
            MAX ( Data[Step] ) = 1, [Value measure:],
            MAX ( Data[Step] ) = _minstepaftersteptwo, [Value measure:] - _steponevalue,
            [Value measure:]
        )
    )

 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.