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
DCELL
Helper III
Helper III

Another running total puzzle

PBIX: https://drive.google.com/file/d/1qQPbUKYFdpr1FMSLQ5Xf5lMfMszB_8yl/view?usp=sharing
EXCEL: https://drive.google.com/file/d/1WdpHyK54pwY99za2YObX0fCc8tV_QYYB/view?usp=sharing

Hi!
I've looked at more than 10 different posts with similar problems, but the solutions don't seem to work for my dataset. I made a sample set that has the same layout as my actual dataset. I have tried many variations of this code:

Running Test =
CALCULATE(
SUM('Sheet2'[amt]),
FILTER(ALL('Sheet2'),
'Sheet2'[Date] <= EARLIER('Sheet2'[Date] )
&& 'Sheet2'[Country] = EARLIER('Sheet2'[Country] )
&& 'Sheet2'[account] = EARLIER('Sheet2'[account] )
))

with using ALL vs ALLSELECT, EARLIER( [Date] ) vs. MAX( [Date] ),  specifying ALL('Sheet2'[Date]), plus combinations of commenting out the [account] and [country] columns. I still don't get the right total in my visual.
It supposed to display the running total by country over time in a stacked column chart, but not by account number, something like this:

 

running total screenshot.png

But the numbers don't line up between pbi and excel. Filtering the Excel sheet for ukr only, for example, gives a total of -2,463,006.92 for the sum of the amounts, while the Power BI visual gives all sorts of numbers.

1 ACCEPTED SOLUTION

Hi @DCELL ,

 

Or What you want is this?

v-lionel-msft_0-1597219827930.png

Measure = 
CALCULATE(
    SUM(Sheet2[amt]),
    FILTER(
        ALL(Sheet2),
        Sheet2[Country] = MAX(Sheet2[Country])&&
        Sheet2[Date] <= MAX(Sheet2[Date])
    )
)

 

Best regards,
Lionel Chen

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

7 REPLIES 7
amitchandak
Super User
Super User

@DCELL , are you trying for column or measure . This will work for column

Running Test =
CALCULATE(
SUM('Sheet2'[amt]),
FILTER(ALL('Sheet2'),
'Sheet2'[Date] <= EARLIER('Sheet2'[Date] )
&& 'Sheet2'[Country] = EARLIER('Sheet2'[Country] )
&& 'Sheet2'[account] = EARLIER('Sheet2'[account] )
))

 

Try for measure

Running Test =
CALCULATE(
SUM('Sheet2'[amt]),
FILTER(ALL('Sheet2'),
'Sheet2'[Date] <= max('Sheet2'[Date] )
&& 'Sheet2'[Country] = max('Sheet2'[Country] )
&& 'Sheet2'[account] = max('Sheet2'[account] )
))

@amitchandak , I think in my case a column would be better, but whichever one works, works.

I tried the column and the measure codes you provided but interestingly both gave different totals on the visual.

Hi @DCELL ,

 

Or What you want is this?

v-lionel-msft_0-1597219827930.png

Measure = 
CALCULATE(
    SUM(Sheet2[amt]),
    FILTER(
        ALL(Sheet2),
        Sheet2[Country] = MAX(Sheet2[Country])&&
        Sheet2[Date] <= MAX(Sheet2[Date])
    )
)

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

@v-lionel-msft Your 2nd solution worked!! I had to remove the account column to get past the extra, double aggregation problem as you said

Hi @DCELL ,

 

v-lionel-msft_0-1597217986806.png

According to your formula, I think what you want is the value of [measure] above, so you must add the above 4 fields in your visuals, otherwise the data will be aggregated. This is true even if you create a calculated column.

v-lionel-msft_1-1597218173471.png

Maybe you can use a matrix?

v-lionel-msft_3-1597219141669.png

 

Best regards,
Lionel Chen

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

parry2k
Super User
Super User

@DCELL can you share pbix file, it is requesting for access.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hi @parry2k  try again now

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.