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

Running Total using measure with multiple filters

Hi, I need help with a couple of measures.
For various reasons, I need to calculate parental Leave based on two measures.  I then add these measures together, and then caculate running total from it.  However, the running total is incorrect.  I've broken each measure down, and the running total on the second measure with more than filter seems to be the problem.

Conditions are as follows;
1. dynamic - based on the date slicer
2. is the count of two different condtions

  a. count where status = "PL  (_mPL3)
  b. count where status <> "PL" and EndDate > StartofMonth(max date slicer)   (_mPL4)

The individual counts for _mPL3 and _mPL4 are correct, but if I separate out the running totals for each measure, then _MPL4 is not correct.
I'm  not sure what is wrong, so if someone it would help immensely.

_mPL3 =

var count_PL = CALCULATE(COUNTROWS('hr Parental Leave2'),'hr Parental Leave2'[Employment Status Code] = "PL",USERELATIONSHIP('hr Date'[TheDate],'hr Parental Leave2'[Start Date]))
return
if (isblank(count_PL),0,count_PL)

_mPL4 =

var Date_Selected = CALCULATE(MAX('hr Date'[TheDate]),ALLSELECTED('hr Date')) 
var som_Date_Selected = DATE(year(Date_Selected), month(Date_Selected), 1) 

var count_PL_b = CALCULATE(COUNTROWS('hr Parental Leave2'),'hr Parental Leave2'[End Date] >= som_Date_Selected ,'hr Parental Leave2'[Employment Status Code] <> "PL" ,USERELATIONSHIP('hr Date'[TheDate],'hr Parental Leave2'[Start Date]))

return if (isblank(count_PL_b),0,count_PL_b)


The Running Total Measure is as follows;

_mPL4_allselected = CALCULATE(
[_mPL4],
FILTER(
ALLSELECTED('hr Date'[TheDate]),
'hr Date'[TheDate]<=MAX('hr Date'[TheDate] )
) )
 
MonthYear_mPL2_mPL2_RunningTotal_mPL3_mPL4_mPL4_allselectedShould be 
Mar-19020020
Apr-19090090
May-1901100110
Jun-1901100110
Jul-1901100110
Aug-1911001101
Sep-192101192
Oct-192102072
Nov-191101062
Dec-191111062
Jan-200110062
Feb-202122052
Mar-202132042
Apr-203153032
May-202162022
Jun-200160022
1 ACCEPTED SOLUTION
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could refer to the following measure:

Measure =
SUMX (
    FILTER (
        ALLSELECTED ( 'hr Date'[TheDate] ),
        'hr Date'[TheDate] <= MAX ( 'hr Date'[TheDate] )
    ),
    [_mPL4]
)

Here are some links about running total of measure.

https://community.powerbi.com/t5/Desktop/Running-total-Cumulative-sum/m-p/1104725

https://community.powerbi.com/t5/Desktop/Running-total-based-on-multiple-measures/m-p/1074564

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

5 REPLIES 5
v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

You could refer to the following measure:

Measure =
SUMX (
    FILTER (
        ALLSELECTED ( 'hr Date'[TheDate] ),
        'hr Date'[TheDate] <= MAX ( 'hr Date'[TheDate] )
    ),
    [_mPL4]
)

Here are some links about running total of measure.

https://community.powerbi.com/t5/Desktop/Running-total-Cumulative-sum/m-p/1104725

https://community.powerbi.com/t5/Desktop/Running-total-based-on-multiple-measures/m-p/1074564

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
amitchandak
Super User
Super User

@Anonymous , the data seem like an output table.

Can you share sample data and sample output in table format?

 

Anonymous
Not applicable

EmployeeKeyPreferred NameSurnameEmployment Status CodeStart DateEnd Date
10100AnnaMcDougalP15/04/2019 0:0026/09/2019 0:00
10101BeaDonaldsonP4/03/2019 0:0031/07/2019 0:00
10102LisaClamorPL18/09/2019 0:007/07/2020 0:00
10103SheilaSmithP25/04/2019 0:006/09/2019 0:00
10104MaryJohnP2/04/2019 0:0020/02/2020 0:00
10105CarolineNevillePL2/12/2019 0:0013/11/2020 0:00
10106LibbyCrumPL14/10/2019 0:0012/10/2020 0:00
10107JulieSpencerPL11/03/2020 0:0011/12/2020 0:00
10108LouiseFishPL17/02/2020 0:008/05/2020 0:00
10109RebeccaMicacPL4/05/2020 0:005/10/2020 0:00
10110ChristinaMongerP27/05/2019 0:0014/06/2019 0:00
10111JulieLee P1/07/2019 0:0026/08/2019 0:00
10112AntoinetteSt TrpezP5/08/2019 0:0030/06/2020 0:00
10113CaitTomanPL16/03/2020 0:004/12/2020 0:00
10114BelindaGaleP29/04/2019 0:0024/04/2020 0:00
10115MonicaBaileyPL21/10/2019 0:007/08/2020 0:00
10116ValeryVallentinePL1/11/2019 0:0030/10/2020 0:00
10117JordanPickeringPL3/04/2020 0:008/07/2020 0:00
10118AvaLeemingPL5/05/2020 0:0027/07/2020 0:00
10119LouseAmandeepF15/04/2019 0:0031/10/2019 0:00
10120LivBozicP8/04/2019 0:002/08/2019 0:00
10121LeeMarksPL4/02/2020 0:0016/03/2020 0:00
10122AnthonyTesmPL20/04/2020 0:0010/07/2020 0:00
10123VonYoungF1/07/2019 0:0015/07/2019 0:00
10124SavRobertsP11/03/2019 0:001/01/2020 0:00
10125janeMcDonaldsP23/09/2019 0:0012/06/2020 0:00
10126GenevieveTanPL14/04/2020 0:006/07/2020 0:00
10127GwenAppleP2/05/2019 0:006/03/2020 0:00
10128KristCanonF1/04/2019 0:003/06/2019 0:00

 

 

And if the Date Slicer Max date is set to 30/06/2020.

Anonymous
Not applicable

pl.png

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.