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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
sjehanzeb
Resolver I
Resolver I

Net Positive Values at a Particular time.

I have table of individual charges and payment for a customer. eg. 

 

Customer IDDateType Amount
11-Jan-2019Services A10,000
130-Mar-2019Payment-8,000
11-Jul-2019Services B6,000
110-Oct-2019Payment-9000


I need to develop receivable of at specific intervals in time (MMM-YY). Simply plotting the Amount column in values establishes that purpose, though when the balance goes negative as in the case of 10th October (Balance = -1,000). the amount also goes negative. Technically it should not go below zero. Is there any way to achieve this? 

 

One way is a add a calculated column to the table that adds the values above - is that the way to go or is there a better way

 
1 ACCEPTED SOLUTION
sjehanzeb
Resolver I
Resolver I

So, I resolved it.
1. using calender table summarized every MMM-YY in the range
2. using the transaction table, summarized all IDs 
3. create a cross table with all values from both tables.
4. Then using addcolumn (to 3) created a calculated column which shows sum of previous activity of individual id. 

 

var mytable1 = ADDCOLUMNS(
    CROSSJOIN(
        SUMMARIZE(Calender, Calender[Year Month], Calender[Year Month Number]), 
        SUMMARIZE(SF, SF[ID])), 
        "Amount",  CALCULATE(sum(SF[Amount]), FILTER(SF, RELATED(Calender[Year Month Number]) <= EARLIER(Calender[Year Month Number]) && SF[Customer ID]=EARLIER(SF[Customer ID]))

 

View solution in original post

4 REPLIES 4
sjehanzeb
Resolver I
Resolver I

So, I resolved it.
1. using calender table summarized every MMM-YY in the range
2. using the transaction table, summarized all IDs 
3. create a cross table with all values from both tables.
4. Then using addcolumn (to 3) created a calculated column which shows sum of previous activity of individual id. 

 

var mytable1 = ADDCOLUMNS(
    CROSSJOIN(
        SUMMARIZE(Calender, Calender[Year Month], Calender[Year Month Number]), 
        SUMMARIZE(SF, SF[ID])), 
        "Amount",  CALCULATE(sum(SF[Amount]), FILTER(SF, RELATED(Calender[Year Month Number]) <= EARLIER(Calender[Year Month Number]) && SF[Customer ID]=EARLIER(SF[Customer ID]))

 

sjehanzeb
Resolver I
Resolver I

What I am looking for is that the amount should not go negative for individual customer. 

 

1. It should be a running total of individual customer

2. Individual customer cannot go negative

 

As discussed, I created a calculated column with each transactions and forced it to not go negative. The problem with that solutions is 

1. When I ran (running total) sum of the calculated column it added multiple balances of the same customer in the given period

2. When I did not (running total) sum the column, the balances of the month where the user did not have any transaction did not show at all. 

 and where the customer had multiple transactions in a period it totaled it also. 


Ultimately, I beleive this could be resolved through creating a seperate table based on this data that shows monthly balance of individual customer whether they had the transactions or not. (I have been trying but have not succeeded in this atempt). 

sjehanzeb
Resolver I
Resolver I

the calculated column (balance) is not working either, if I sum the figure from previous values, they are inflated as balance is already a sum. If I don't sum it,

 

  • it is adding multiple balance of same customer in a month
  • not adding any value of customer if it does not have a transaction in that month

if we go with a balance approach, it should show a monthly single line item by each customer every month (based on the last transaction) regardless of any transaction in that month. 

 

Hi  @sjehanzeb ,

 

Create a measure as below:

Measure = 
CALCULATE(SUM('Table'[Amount]),FILTER(ALL('Table'),'Table'[Date]<=MAX('Table'[Date])&&'Table'[Customer ID]=MAX('Table'[Customer ID])))

 And you will see:

v-kelly-msft_0-1614584846636.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors