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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Andshepch
Advocate II
Advocate II

Running Total with exclusions

Hi all,

I am trying to recreate a chart that the business uses currently in Excel, that I would like to move to Power BI. It is like a waterfall chart, but has Targets included in the chart as well (Budget and Forecast) like this:

Andshepch_0-1656676829685.png

 

to do this we have a table like this:

CategoryCV €MIndexCV €M 2Base 2Base 3
Q1Sold Churn1.8301.830.000.00
Q1 Unsold Churn4.9814.981.831.83
Q1 Sold Medium1.3421.346.816.81
Q1 Unsold Medium3.5933.598.158.15
Fcst Q125.2240.0011.740.00
Bud Q125.0450.0011.740.00
Q2 Sold Churn1.8361.8311.7411.74
Q2 Unsold Churn4.9874.9813.5713.57
Q2 Sold Medium1.3481.3418.5518.55
Q2 Unsold Medium3.5993.5919.8919.89
Deal 18.20108.2023.4823.48
Deal 26.20116.2031.6831.68
Deal 35.30125.3037.8837.88
H1 YTD Fcst56.09130.0043.180.00
H1 YTD Bud70.14140.0043.180.00
Q3 Unsold Churn6.81156.8143.1843.18
Q3 Unsold Medium4.93164.9349.9949.99
Deal 417.301717.3054.9254.92
Deal 54.60184.6072.2272.22
Q3 YTD Fcst99.27190.0076.820.00
Q3 YTD Bud98.23200.0076.820.00
Q4 Unsold Churn6.81216.8176.8276.82
Q4 Unsold Medium4.93224.9383.6383.63
Deal 65.60235.6088.5688.56
Deal 71.90241.9094.1694.16
FY YTD Fcst145.44250.0096.060.00
FY YTD Bud145.44260.0096.060.00

 

The first 3 columns (Category, CV €M and Index) are the data table that we get from another system, and the last 3 columns are calculated:

CV €M 2 is simply the CV €M column, but Zero when the Category contains "Bud" or "Fcst"

Base 2 is the running total of CV €M 2 but offset by 1 row
Base 3 is Base 2, but Zero when the Category contains "Bud" or "Fcst"

We then use CV €M and Base 3 for the chart data

I am trying to calculate measures in DAX (Not M) to replicate these columns, and I can get to a running total:

 

Cumulative Base =
CALCULATE (
[CV €M],
FILTER (
ALLSELECTED ( 'FY Chart Data' ),
'FY Chart Data'[Rank] < MAX ( 'FY Chart Data'[Rank] )
)
)
 
But I am going round in circles tryng to do the offset, and then the Zero values wher the category is "Bud" or "Fcst". Any and all help/pointers would be greatly appreciated.
 
Thank you

 

 

1 ACCEPTED SOLUTION
v-jianboli-msft
Community Support
Community Support

Hi @Andshepch ,

 

Here is the DAX of these columns:

 

CV €M 2 =
IF (
    CONTAINSSTRING ( [Category], "Fcst" ) || CONTAINSSTRING ( [Category], "Bud" ),
    0,
    [CV €M]
)

Base 2 =
VAR _a =
    CALCULATE (
        SUM ( Table1[CV €M 2] ),
        FILTER ( Table1, [Index] < EARLIER ( [Index] ) )
    )
RETURN
IF ( ISBLANK ( _a ), 0, _a )

Base 3 =
IF (
    CONTAINSSTRING ( [Category], "Fcst" ) || CONTAINSSTRING ( [Category], "Bud" ),
    0,
    [Base 2]
)

 

Final output:

vjianbolimsft_0-1657012498473.png

 

Best Regards,

Jianbo Li

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
v-jianboli-msft
Community Support
Community Support

Hi @Andshepch ,

 

Here is the DAX of these columns:

 

CV €M 2 =
IF (
    CONTAINSSTRING ( [Category], "Fcst" ) || CONTAINSSTRING ( [Category], "Bud" ),
    0,
    [CV €M]
)

Base 2 =
VAR _a =
    CALCULATE (
        SUM ( Table1[CV €M 2] ),
        FILTER ( Table1, [Index] < EARLIER ( [Index] ) )
    )
RETURN
IF ( ISBLANK ( _a ), 0, _a )

Base 3 =
IF (
    CONTAINSSTRING ( [Category], "Fcst" ) || CONTAINSSTRING ( [Category], "Bud" ),
    0,
    [Base 2]
)

 

Final output:

vjianbolimsft_0-1657012498473.png

 

Best Regards,

Jianbo Li

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

tamerj1
Super User
Super User

Hi @Andshepch 

please try

 

Cumulative Base =
VAR SelectedData =
    ALLSELECTED ( 'FY Chart Data' )
VAR CurrentRank =
    MAX ( 'FY Chart Data'[Rank] )
VAR PreviousData =
    FILTER (
        SelectedData,
        'FY Chart Data'[Rank] <= CurrentRank
            && NOT ( 'FY Chart Data'[category] IN { "Bud", "Fcst" } )
    )
RETURN
    CALCULATE ( [CV €M], PreviousData )

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors