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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
goncalogeraldes
Super User
Super User

Percentage of Running Total for a Matrix

Hello there! I am trying to obtain the running total for the percentagem of the total value. I have tried many solutions that I found here in the community but they all turn out like in the image. That is, it is calculating "correctly" but not in the correct order. What I want in the first row is 21,89%, second row 42,69, third row 52,84 and so on... Currently it is calculating the percentages in alphabetical order but I need it by the total sum (please note that the "€" is sorted)

 

goncalogeraldes_0-1629906332784.png

 

Thanks in advance!! 

Gonçalo Costa

 

10 REPLIES 10
v-stephen-msft
Community Support
Community Support

Hi @goncalogeraldes ,


Could you tell me if your problem has been solved?
If it is, kindly Accept the useful reply as the solution. More people will benefit from it.
Or you are still confused about it, please provide me with more details about your problem.


Best Regards,
Stephen Tao

Unfortunately I still do not have a solution to this... I have tried many methods but none seems to work... Thanks for your suggestions though!

PaulDBrown
Community Champion
Community Champion

Create a measure for the total sales, using something along the lines of:

Total sales by customer= CALCULATE ([Sum sales], ALL(table[Customer name))

 

and finally use your current running total in 

% running total = DIVIDE( [your running total measure], [Total sales by customer])





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






@PaulDBrown Thanks for your reply for unfortunately this wont work. The problem is the same as in the print I sent the response to nvprasad reply

There must be something going on with the filter context. Here is a quick example:

Cumul. sales by product ref =
VAR Rnk = [RANK Sales by Product Ref]
RETURN
    IF (
        ISINSCOPE ( 'DIM Product Ref'[Product REF] ),
        CALCULATE (
            [Sum of Sales],
            FILTER (
                ALL ( 'DIM Product Ref'[Product REF] ),
                [RANK Sales by Product Ref] <= Rnk
            )
        )
    )

 

 

 

Sales all prod ref = CALCULATE([Sum of Sales], ALL('DIM Product Ref'[Product REF]))
% cumulative = DIVIDE([Cumul. sales by product ref], [Sales all prod ref])

 

 

Captura.JPG

 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






nvprasad
Solution Sage
Solution Sage

Hi goncalogeraldes,

I am hoping you are trying to calculate running % based on date.

Running%Total =
Var RunningTotal = CALCULATE([Sales Amount],FILTER(ALL('Date'),'Date'[Date]<=MIN('Date'[Date])))
Var TotalSales = CALCULATE([Sales Amount],ALL('Date'))
Var result = DIVIDE(RunningTotal,TotalSales,0)
Return result
 

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

@nvprasad Thanks for the fast response! The problem here is that this based on the Customer Name and not the Date column so unfortunately this wont work... This one is actually quite similar to the one I have now!

Hi,

 

Could you please check with the below logic.

 

RunningTotal%Check =

Var rankcheck = RANKX ( ALL ( 'Product'[Product Name] ), [Sales Amount],, DESC )
Var runningTotal = CALCULATE([Sales Amount], FILTER(ALL('Product'[Product Name]),RANKX ( ALL ( 'Product'[Product Name] ), [Sales Amount],, DESC )<=rankcheck))
Var totalSales = CALCULATE([Sales Amount],ALL('Product'[Product Name]))
Return DIVIDE(runningTotal,totalSales,0)

Appreciate a Kudos! 🙂
If this helps and resolves the issue, please mark it as a Solution! 🙂

Regards,
N V Durga Prasad

 

Hi there @nvprasad ! Thanks for the help! Unfortunately this is the result with your formula...

 

goncalogeraldes_0-1629966182424.png

 

goncalogeraldes_1-1629966210369.png

 

Any ideas on what is hapenning? 

 

@nvprasad I swithched the order of the "rankcheck" and the "runningtotal" and it makes a little bit more sense but it gives the opposite result of what i need. I think its almost there! Here is the result:

 

goncalogeraldes_2-1629966503503.png

 

goncalogeraldes_3-1629966537429.png

I need it reversed!

 

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.