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

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

Reply
MeetShah
Frequent Visitor

DAX function to get Cumulative Subtraction

MeetShah_0-1677486655911.png

Here I have scenario where I have following values
1. Total TestRuns =28
2. Number of working days = 5
3. Date Range
Using which I need to generate the Expected Output which is highlighted in Orange color column where Total Runs count keeps decereasing by 5.6 as the date changes.


1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @MeetShah ,

 

Here are the steps you can follow:

1. Create calculated column.

Rank =
RANKX(
    'Table','Table'[Date],,ASC)
Flag =
var _workingdays=
COUNTX(FILTER(ALL('Table'),
NOT(WEEKDAY('Table'[Date],2)) in {6,7}),[Date])
var _nooftestruns=28
var _value1=DIVIDE(28,5)
return
IF(
    'Table'[Rank] = MINX(ALL('Table'),[Rank]),
    _nooftestruns,
    - _value1)
Output =
SUMX(
    FILTER(ALL('Table'),
    'Table'[Rank]<=EARLIER('Table'[Rank])),[Flag])

2. Result:

vyangliumsft_0-1677634356197.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

2 REPLIES 2
Anonymous
Not applicable

Hi  @MeetShah ,

 

Here are the steps you can follow:

1. Create calculated column.

Rank =
RANKX(
    'Table','Table'[Date],,ASC)
Flag =
var _workingdays=
COUNTX(FILTER(ALL('Table'),
NOT(WEEKDAY('Table'[Date],2)) in {6,7}),[Date])
var _nooftestruns=28
var _value1=DIVIDE(28,5)
return
IF(
    'Table'[Rank] = MINX(ALL('Table'),[Rank]),
    _nooftestruns,
    - _value1)
Output =
SUMX(
    FILTER(ALL('Table'),
    'Table'[Rank]<=EARLIER('Table'[Rank])),[Flag])

2. Result:

vyangliumsft_0-1677634356197.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

Hey this worked.
Thank You!

 

Helpful resources

Announcements
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