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
sam_hoccane
Helper I
Helper I

Cumulative Emission with Filter condition

Hi Community,

Data PowerBI File

Could you please help me finding cummulative emission with Filter condition 

 

I want to create a measure that can calculate emission up till Forecast value is "N".  I  am trying with following measure but I am still getting values where forecast is "Y".  so, my goal is create  measure that calculate cummulative total up till  Forecast value is "N" and rest is blank.    I guess it is happenig becasue of ALL. 

 

Actual Cumulative Emissions =
VAR _table = FILTER ( ALLSELECTED(data), data[Date] <= MAX( data[Date])&&data[Forecast]="N")
VAR _cumulative_before_forecast = CALCULATE( SUM(data[Emission]) , _table)
Return   _cumulative_before_forecast
 
 
sam_hoccane_2-1658506133143.png

 


My expected results should look like this

sam_hoccane_1-1658505950484.png

 

Thankyou in Anticipation

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@sam_hoccane , Try one of the two

 

Actual Cumulative Emissions =
VAR _max = maxx(filter(allselected(data) ,data[Forecast]="N"), data[Date])
VAR _cumulative_before_forecast = CALCULATE( SUM(data[Emission]) , FILTER ( ALLSELECTED(data), data[Date] <= MAX( data[Date]) && data[Date] <=_max && data[Forecast]="N"))
Return _cumulative_before_forecast

 


Actual Cumulative Emissions =
VAR _max = maxx(filter(allselected(data) ,data[Forecast]="N"), data[Date])
VAR _cumulative_before_forecast = if( max(data[Date]) <=_max ,CALCULATE( SUM(data[Emission]) , FILTER ( ALLSELECTED(data), data[Date] <= MAX( data[Date]) && data[Forecast]="N")), blank())
Return _cumulative_before_forecast

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Anonymous
Not applicable

Hi @sam_hoccane ,

I have created a simple sample, please refer to my pbix file to see if it help you.

Create a measure.

Measure =
VAR _result =
    CALCULATE (
        SUM ( 'Table'[Emission] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] <= SELECTEDVALUE ( 'Table'[date] )
                && 'Table'[Forecasst] = "N"
        )
    )
RETURN
    IF ( MAX ( 'Table'[Forecasst] ) = "N", _result, BLANK () )

Or a column.

Column =
VAR _result =
    CALCULATE (
        SUM ( 'Table'[Emission] ),
        FILTER (
            ( 'Table' ),
            'Table'[date] <= EARLIER ( 'Table'[date] )
                && 'Table'[Forecasst] = "N"
        )
    )
RETURN
    IF ( 'Table'[Forecasst] = "N", _result, BLANK () )

vpollymsft_1-1658808294428.png

If I have misunderstood your meaning, please provide your pbix file without privacy information and your desired output with more details.

 

Best Regards

Community Support Team _ Polly

 

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

3 REPLIES 3
sam_hoccane
Helper I
Helper I

@amitchandak Thank you. It wokred . 

Anonymous
Not applicable

Hi @sam_hoccane ,

I have created a simple sample, please refer to my pbix file to see if it help you.

Create a measure.

Measure =
VAR _result =
    CALCULATE (
        SUM ( 'Table'[Emission] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] <= SELECTEDVALUE ( 'Table'[date] )
                && 'Table'[Forecasst] = "N"
        )
    )
RETURN
    IF ( MAX ( 'Table'[Forecasst] ) = "N", _result, BLANK () )

Or a column.

Column =
VAR _result =
    CALCULATE (
        SUM ( 'Table'[Emission] ),
        FILTER (
            ( 'Table' ),
            'Table'[date] <= EARLIER ( 'Table'[date] )
                && 'Table'[Forecasst] = "N"
        )
    )
RETURN
    IF ( 'Table'[Forecasst] = "N", _result, BLANK () )

vpollymsft_1-1658808294428.png

If I have misunderstood your meaning, please provide your pbix file without privacy information and your desired output with more details.

 

Best Regards

Community Support Team _ Polly

 

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

 

 

amitchandak
Super User
Super User

@sam_hoccane , Try one of the two

 

Actual Cumulative Emissions =
VAR _max = maxx(filter(allselected(data) ,data[Forecast]="N"), data[Date])
VAR _cumulative_before_forecast = CALCULATE( SUM(data[Emission]) , FILTER ( ALLSELECTED(data), data[Date] <= MAX( data[Date]) && data[Date] <=_max && data[Forecast]="N"))
Return _cumulative_before_forecast

 


Actual Cumulative Emissions =
VAR _max = maxx(filter(allselected(data) ,data[Forecast]="N"), data[Date])
VAR _cumulative_before_forecast = if( max(data[Date]) <=_max ,CALCULATE( SUM(data[Emission]) , FILTER ( ALLSELECTED(data), data[Date] <= MAX( data[Date]) && data[Forecast]="N")), blank())
Return _cumulative_before_forecast

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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.