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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
arturocastillo
Frequent Visitor

Cumulative sales per day and other fields

Hello,

 

I'm designing a report for a sales analysis. However, I have the next problem. I want to present a cumulative sales per day and per service and region of my company but when I show this, the cumulative does not show the correct amount but repeats the total sum.

 

1.png

2.png

 

 

But when I don't use the field region or service the cumulative per day is correct

3.png

 

Actually I am using the next formula:

cumulative = SUMX(FILTER(ALLSELECTED('table_sales'),'table_sales'[date]<=MAX('table_sales'[date])),'table_sales'[quantity])

 

When I use the tipical formula I don´t have any difference:

cumulative = CALCULATE (
        SUM ( 'table_sales'[quantity] ),
        FILTER (
            ALLSELECTED ( 'table_sales'),
            'table_sales'[date] <= MAX ( 'table_sales'[date] )
        )
    )

 

I expect have the next result:

4.png

 

Is it necessary add any other function to my formula?

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@arturocastillo

 

Hi, one way to solve this:

 

Create a calculated Column

 

Index =
VAR RegionRank =
    RANKX ( Table1, Table1[Region],, DESC, DENSE )
VAR ServiceRank =
    RANKX ( Table1, Table1[Service],, DESC, DENSE )
RETURN
    ( [Day] * 100 )
        + ( RegionRank * 10 )
        + ServiceRank

After that Create a New Measure

 

RunningTotal =
CALCULATE (
    SUM ( 'Table1'[Sales] ),
    FILTER ( ALLSELECTED ( Table1[Index] ), Table1[Index] <= MAX ( Table1[Index] ) ),
    ALLEXCEPT ( Table1, Table1[Index] )
)

 

Maybe You need some adjust to sort the table visual.

 

Regards

 

Victor

Lima - Peru




Lima - Peru

View solution in original post

4 REPLIES 4
Vvelarde
Community Champion
Community Champion

@arturocastillo

 

Hi, one way to solve this:

 

Create a calculated Column

 

Index =
VAR RegionRank =
    RANKX ( Table1, Table1[Region],, DESC, DENSE )
VAR ServiceRank =
    RANKX ( Table1, Table1[Service],, DESC, DENSE )
RETURN
    ( [Day] * 100 )
        + ( RegionRank * 10 )
        + ServiceRank

After that Create a New Measure

 

RunningTotal =
CALCULATE (
    SUM ( 'Table1'[Sales] ),
    FILTER ( ALLSELECTED ( Table1[Index] ), Table1[Index] <= MAX ( Table1[Index] ) ),
    ALLEXCEPT ( Table1, Table1[Index] )
)

 

Maybe You need some adjust to sort the table visual.

 

Regards

 

Victor

Lima - Peru




Lima - Peru

Thanks @Vvelarde! The help you gave me by private messagges was very good. I have some fields which help me to classify my data and them have to add in an exception.

 

The final formula was:

RunningTotal =
CALCULATE(
SUM('Table1'[Sales]);FILTER(ALLSELECTED(Table1[Index]);Table1[Index]<=MAX(Table1[Index]));ALLEXCEPT(Table1;Table1[Index];Table1[Region];Table1[Service]))

@Vvelarde

 

Hi, I still have the same problem. The cumulative doesn't show like I expect. We can continue the conversation in spanish by private messages?

Hi @arturocastillo,

 

You can firstlt add an index column in Query Editor mode.

 

Then, create a measure like below:

Running value =
CALCULATE (
    SUM ( table_sales[sales] ),
    FILTER ( ALL ( table_sales ), table_sales[Index] <= MAX ( table_sales[Index] ) )
)

2.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.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors