cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jorge1986 Frequent Visitor
Frequent Visitor

Error in a measure using Earlier

Hi, 

I have a table called factVentas with lots of data, I need a dynamic report of paretto 80 20 by dates. The issue is that I have an error in making an accumulated sum within a measure.

 

Something like this.

Imagen1.jpg

where $SumValue and $Total1 are measured with the following formulas:

 

$SumValue = SUM (factVentas[VENTA NETA] )

 

$Total1 = SUMX(ALLSELECTED(factVentas), factVentas[VENTA NETA])

 

 Now, what is needed is to accumulate the value of $SumValue row by row, and I do it in the following way:

Imagen2.jpg

 

$VentasAcumuladas = SUMX(FILTER(factVentas, EARLIER(factVentas[$SumValue],1)<=factVentas[$SumValue]),factVentas[$SumValue])

The error says:  EARLIER/EARLIEST refers to an earlier row context which doesn't exist.

This formula works well on a column, but I have this error as a measure. Any help in this case would be greatly appreciated. Greetings.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-yulgu-msft Super Contributor
Super Contributor

Re: Error in a measure using Earlier

Hi @Jorge1986,

 

EARLIER/EARLIEST function can be used in calculated column only , but not supported within a measure.

 

In your scenario, please first create a calculated column in 'facyVentas':

Rank col =
RANKX (
    ALL ( factVentas ),
    CALCULATE (
        SUM ( factVentas[VENTA NETA] ),
        ALLEXCEPT ( factVentas, factVentas[Category] )
    ),
    ,
    DESC,
    DENSE
)

Then, create a measure to return accumulated sum:

$VentasAcumuladas =
CALCULATE (
    SUM ( factVentas[VENTA NETA] ),
    FILTER (
        ALL ( factVentas ),
        factVentas[Rank col] <= MAX ( factVentas[Rank col] )
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

Jorge1986 Frequent Visitor
Frequent Visitor

Re: Error in a measure using Earlier

Dear @v-yulgu-msft, His contribution was vital to reach the solution, for my case I had to make small modifications and in that way make him work dynamically. Thank you very much, enormous support, enormous brain ... Greetings from Ecuador.

View solution in original post

2 REPLIES 2
v-yulgu-msft Super Contributor
Super Contributor

Re: Error in a measure using Earlier

Hi @Jorge1986,

 

EARLIER/EARLIEST function can be used in calculated column only , but not supported within a measure.

 

In your scenario, please first create a calculated column in 'facyVentas':

Rank col =
RANKX (
    ALL ( factVentas ),
    CALCULATE (
        SUM ( factVentas[VENTA NETA] ),
        ALLEXCEPT ( factVentas, factVentas[Category] )
    ),
    ,
    DESC,
    DENSE
)

Then, create a measure to return accumulated sum:

$VentasAcumuladas =
CALCULATE (
    SUM ( factVentas[VENTA NETA] ),
    FILTER (
        ALL ( factVentas ),
        factVentas[Rank col] <= MAX ( factVentas[Rank col] )
    )
)

1.PNG

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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

Jorge1986 Frequent Visitor
Frequent Visitor

Re: Error in a measure using Earlier

Dear @v-yulgu-msft, His contribution was vital to reach the solution, for my case I had to make small modifications and in that way make him work dynamically. Thank you very much, enormous support, enormous brain ... Greetings from Ecuador.

View solution in original post

Helpful resources

Announcements
Ask Amir Anything

Exclusive LIVE Community Event No. 2 – Ask Amir Anything

Next in our Triple A series: Ask Amir Netz questions about the latest updates, features and future.

Ask Amanda Anything Q&A

Ask Amanda Anything Q&A

Learn the answers to some of the questions asked during the Amanda Triple A event.

October 2019 Community Highlights

October 2019 Community Highlights

October was a busy month in the community. Read the recap article to learn about some of the events and content.

New Solution Badges

New Solution Badges

Two waves of brand new solution badges are coming! Read the article for more information on our new community badges.

Users Online
Currently online: 6 members 1,721 guests
Please welcome our newest community members: