cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Midhun
Regular Visitor

Not able to select column when using earlier function

Hello Experts,

       I am tryiting to find the cumulative sum . when using below code i was not able to chse my column after earlier function. Please suggest

cumulative= CALCULATE(SUM(Email_Campaign[valid]),
all(Email_Campaign),Email_Campaign[Dummy_Date]<=EARLIER(
1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @Midhun ,

 

EARLIER function is useful to calculated column. Please check whether you are using it for measure.

 

You can use MAX function instead of EARLIER.

 

cumu = CALCULATE(
sum(Email_Campaign[Valid_Email]),
FILTER(
ALL( Email_Campaign[Dummy_Date] ),
Email_Campaign[Dummy_Date] <= MAX(Email_Campaign[Dummy_Date])
)
)

 

 

Best Regards,

Stephen Tao

 

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

Hi @Midhun ,

 

EARLIER function is useful to calculated column. Please check whether you are using it for measure.

 

You can use MAX function instead of EARLIER.

 

cumu = CALCULATE(
sum(Email_Campaign[Valid_Email]),
FILTER(
ALL( Email_Campaign[Dummy_Date] ),
Email_Campaign[Dummy_Date] <= MAX(Email_Campaign[Dummy_Date])
)
)

 

 

Best Regards,

Stephen Tao

 

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

Midhun
Regular Visitor

I tried with your DAX, still facing an issue. stating that

ARLIER/EARLIEST refers to an earlier row context which doesn't exist.

 

cumu = CALCULATE(
sum(Email_Campaign[Valid_Email]),
FILTER(
ALL( Email_Campaign[Dummy_Date] ),
Email_Campaign[Dummy_Date] <= EARLIER(Email_Campaign[Dummy_Date])
)
)
CNENFRNL
Community Champion
Community Champion

DAX engine interprets this filter modifier

 CALCULATE( ... Email_Campaign[Dummy_Date] <= EARLIER( Table[someColumn] ) )

as

= CALCULATE(
    ...,
    FILTER(
        ALL( Email_Campaign[Dummy_Date] ),
        Email_Campaign[Dummy_Date] <= EARLIER( Table[someColumn] )
    )
)

and FILTER( ... ) evaluates under the filter context outside CALCULATE(); obviously, there's no row context avaible for EARLIER.

 

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Power BI October Update 2021.jpg

Power BI Release

Click here to read more about the October 2021 Release!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Teds Dev Camp Oct. 2021 768x460.jpg

Power BI Dev Camp - October 28th, 2021

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors
Top Kudoed Authors