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
Anonymous
Not applicable

Sum up sales from customers

Hi everyone,

 

I have a problem where i am trying to sum up the sales (create a balance) for my customers based on when the sale was made.

 

I have the posting date of the sale, along with the customer and the amount.

I would like to sum up the sales based on the date. 

In my example i have the wanted column "balance", which sums up the amount from the posting date and earlier posts.

Without taking the "entry no." into account (since that complicates things). I wouldn't mind having the balance for the date being the total of all sales as seen for customer B's two posts on the 30/01/2019. The sales are both 5, but since i just look at the date, the total would say 10.

 

What would be even nicer is the column "better balance" where it simply looks at the "entry no." and "customer" to sum up the row and previous rows fulfilling the criteria. So the first "balance" for B would be 5, and then 10 as it finds the next entry from customer B.

 

I just can't seem to get it to work. i have tried EARLIER, FILTER, SELECTEDVALUE, FINDVALUE and others.

2019-03-01_1225.png

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @Anonymous,

 

You can try to use following calculated column formulas if they suitable for your requirement:

balance =
CALCULATE (
    SUM ( Table[Sale] ),
    FILTER (
        ALL ( Table ),
        [Customer] = EARLIER ( Table[Customer] )
            && [Posting Date] = EARLIER ( Table[Posting Date] )
    )
)


Better balance =
CALCULATE (
    SUM ( Table[Sale] ),
    FILTER (
        ALL ( Table ),
        [Customer] = EARLIER ( Table[Customer] )
            && [Posting Date] <= EARLIER ( Table[Posting Date] )
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @Anonymous,

 

You can try to use following calculated column formulas if they suitable for your requirement:

balance =
CALCULATE (
    SUM ( Table[Sale] ),
    FILTER (
        ALL ( Table ),
        [Customer] = EARLIER ( Table[Customer] )
            && [Posting Date] = EARLIER ( Table[Posting Date] )
    )
)


Better balance =
CALCULATE (
    SUM ( Table[Sale] ),
    FILTER (
        ALL ( Table ),
        [Customer] = EARLIER ( Table[Customer] )
            && [Posting Date] <= EARLIER ( Table[Posting Date] )
    )
)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

The code you pasted for "balance" and "better balance" is the same. Was that an accident?

Hi @Anonymous ,

 

Nope, they are different. One of the formula condition is 'equal to' current post date, the other one is 'less than or equal to' current post date.

 

So the second one will look up the cumulative result based on current date.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help 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.