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