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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
lngshrmn_phil
Frequent Visitor

Need help with running total measure

Hello, 

I have a dataset which has portfolios, months on book(MOB), and mob_buckets (groupings of portfolios into mob <=3, between 4 and 6, between 7 and 9, etc.). I have created a measure ltr_001_perc which calculates the proportion of accounts in each portfolio which had a letter sent to them during one of the mob or mob buckets (see below). 

{

var ltr = SUM(TBL_PORT_PERF_FINAL[LTR_001])
var a = sum(dist_pool_id[ACCT_COUNT])
var b = CALCULATE(a, ALLEXCEPT(TBL_PORT_PERF_FINAL, TBL_PORT_PERF_FINAL[POOL_ID]))

return
divide(ltr, b)  
}

I have also created a cumulative measure which shows a running total on each mob (see below).
 {
calculate(
  [ltr_001_perc],
    filter(
        allselected(TBL_PORT_PERF_FINAL[MOB]),
        isonorafter(TBL_PORT_PERF_FINAL[MOB], max(TBL_PORT_PERF_FINAL[MOB]), desc)
    )
)
}
 
I need to replicate this measure for mob buckets but everything I try is incorrect. This is what I am currently working with, but yields inaccurate results that drop off at mob bucket 9 
 
{
var MaxDate = SELECTEDVALUE(TBL_PORT_PERF_FINAL[MOB_BUCKET])
var Result =
            CALCULATE(
                [ltr_001_perc],
                TBL_PORT_PERF_FINAL[MOB_BUCKET]<= MaxDate,
                ALL(TBL_PORT_PERF_FINAL[MOB_BUCKET])          
)

return
Result
}
2 REPLIES 2
Greg_Deckler
Super User
Super User

@lngshrmn_phil See if this helps: Better Running Total - Microsoft Power BI Community

 

If not, Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler 

This is a few columns of one portfolio.

POOL_ID|POOL_ID_SHORT|PURCH_ENT|FUND_MO                |VINTAGE|MOB|MOB_BUCKET|
-------+-------------+---------+-----------------------+-------+---+----------+
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021|  0|3         |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021|  1|3         |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021|  2|3         |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021|  3|3         |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021|  4|6         |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021|  5|6         |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021|  6|6         |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021|  7|9         |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021|  8|9         |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021|  9|9         |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021| 10|12        |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021| 11|12        |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021| 12|12        |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021| 13|>12       |
BARNI3 |BAR          |Core     |2021-12-01 00:00:00.000|   2021| 14|>12       |

 

My expected output for the bottom visual is something like you see in the top visual (see below). As you can see, even when disregarding the stalling summation, the numbers are incorrect as each mob bucket should match the corresponding mob from the top visual. 

 

lngshrmn_phil_0-1675429239923.png

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.