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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
grkanth81
Helper II
Helper II

help needed to get the cumulative of distinct values per period

Hi all,

We are using Power BI Report Server (May 2025 version). I would like to get cumulative/running total of BilledAmount distinct values per period. 

Here is my sample test data:

PeriodDateValueEmployeeIDBilledAmount
2026011/07/202512345634900.8
2026012/07/202512345634900.8
2026018/07/202512345634900.8
20260115/07/202512345634900.8
20260118/07/202512345634900.8
2026023/08/202512345644158.94
20260213/08/202512345644158.94
20260229/08/202512345644158.94
2026035/09/202512345638486.41
20260312/09/202512345638486.41
2026041/10/202512345662589.27
20260410/10/202512345662589.27
20260415/10/202512345662589.27
20260421/10/202512345662589.27
202605 123456 
202606 123456 
202607 123456 
202608 123456 
202609 123456 
202610 123456 
202611 123456 
202612 123456 

 

The below DateTable holds the data from 01/06/2025 to 30/06/2026

DateTable =

ADDCOLUMNS(

    CALENDAR(MIN('Table'[DateValue]), MAX('Table'[DateValue])),

    "Year", YEAR([Date]),

    "Month", FORMAT([Date], "MMM YYYY"),

    "MonthNumber", MONTH([Date]),

    "Dayint", DAY([Date]),

    "DayName",FORMAT([Date], "ddd"),  

    "Day",FORMAT([Date], "dd (ddd)")

)

 

And added the below columns to the above:

FY Period =

VAR CurrentMonth = MONTH(DateTable[Date])

VAR CurrentYear = YEAR(DateTable[Date])

VAR FiscalYear = IF(CurrentMonth >= 7, CurrentYear + 1, CurrentYear)

VAR FiscalMonth = IF(CurrentMonth >= 7, CurrentMonth - 6, CurrentMonth + 6)

RETURN

    FiscalYear * 100 + FiscalMonth

 

Fiscal Year = LEFT(DateTable[FY Period],4)

 

As there are distinct values in the result set, finding tricky. can someone help with this ?

Thanks,

grkanth81

1 ACCEPTED SOLUTION
v-dineshya
Community Support
Community Support

Hi @grkanth81 ,

Thank you for reaching out to the Microsoft Community Forum.

 

As you mentioned in your question, you want to get cumulative/running total of BilledAmount distinct values per period. 

 

Please refer  below output snaps for both EmployeeID's and attached PBIX file.

 

vdineshya_0-1761562034362.png

 

vdineshya_1-1761562098271.png

 

I hope this information helps. Please do let us know if you have any further queries.

 

Regards,

Dinesh

 

View solution in original post

7 REPLIES 7
v-dineshya
Community Support
Community Support

Hi @grkanth81 ,

Thank you for reaching out to the Microsoft Community Forum.

 

As you mentioned in your question, you want to get cumulative/running total of BilledAmount distinct values per period. 

 

Please refer  below output snaps for both EmployeeID's and attached PBIX file.

 

vdineshya_0-1761562034362.png

 

vdineshya_1-1761562098271.png

 

I hope this information helps. Please do let us know if you have any further queries.

 

Regards,

Dinesh

 

Thank you  v-dineshya. That worked.

 

Thanks,

grkanth81

grkanth81
Helper II
Helper II

Thanks Aala_Ali & AnalyticPulse.

I tried both your codes and it looks like both are not working as expected. I am not sure if I am doing anything wrong from my side. I am not able to upload  the pbix file and there is a EmployeeID filter slicer. So the cumulatives should work for every employee. The final cumulative billed amounts for employees should be as below:

PeriodEmployeeIDCumulativeBilledAmount
20260112345634900.8
20260212345679,059.74
202603123456117,546.15
202604123456180,135.42
   
PeriodEmployeeIDCumulativeBilledAmount
20260178999979,679.50
202602789999159,676.72
202603789999180,573.72
202604789999180,617.22

 

Here is the sample data for couple of employees:

PeriodDateValueEmployeeIDBilledAmount
2026011/07/202512345634900.8
2026012/07/202512345634900.8
2026018/07/202512345634900.8
20260115/07/202512345634900.8
20260118/07/202512345634900.8
2026023/08/202512345644158.94
20260213/08/202512345644158.94
20260229/08/202512345644158.94
2026035/09/202512345638486.41
20260312/09/202512345638486.41
2026041/10/202512345662589.27
20260410/10/202512345662589.27
20260415/10/202512345662589.27
20260421/10/202512345662589.27
202605 123456 
202606 123456 
202607 123456 
202608 123456 
202609 123456 
202610 123456 
202611 123456 
202612 123456 
2026015/07/202578999979679.5
20260112/07/202578999979679.5
20260114/07/202578999979679.5
20260122/07/202578999979679.5
20260128/07/202578999979679.5
2026027/08/202578999979997.22
20260220/08/202578999979997.22
20260231/08/202578999979997.22
20260312/09/202578999920897
20260324/09/202578999920897
2026043/10/202578999943.5
2026049/10/202578999943.5
20260410/10/202578999943.5
20260417/10/202578999943.5
202605 789999 
202606 789999 
202607 789999 
202608 789999 
202609 789999 
202610 789999 
202611 789999 
202612 789999 

 

When I tried with your codes, this is what I can see:

grkanth81_0-1761305199656.png

 

grkanth81_1-1761305232715.png

Can you please advise if I am doing anything wrong ?

 

Thanks,

grkanth81

Hi @grkanth81 
Okay I got your point, I assume the EmployeeID slicer was the issue because we use ALL('Table') inside the measure was wiping out the EmployeeID filter, so it was summing all employees instead of just the one selected.

try to add keep filter and your measure will be like this  :

Distinct Billed per Period :=
VAR curPeriod = SELECTEDVALUE ( DateTable[FY Period] )
RETURN
SUMX (
VALUES ( 'Table'[EmployeeID] ),
CALCULATE (
MAX ( 'Table'[BilledAmount] ), 
KEEPFILTERS ( 'Table'[FY Period] = curPeriod )
)
)

I hope this help you to solve your problem if so, Please mark it as Solution and give Kudo.

Thanks Aala_Ali for your reply/ I tried your new code and I can see that now Distinct Billed per Period it is picking up the max values per period and by using the EmployeeID slicer. But there seems to be no change in the Cumulative Distinct Billed. They are still showing the same original max values per period but doing cumulatives.

 

grkanth81_0-1761458899698.png

 

Thanks,

Ravi

Aala_Ali
Responsive Resident
Responsive Resident

Hi @grkanth81 ,

If I got your point correctly

Bring FY Period down to the fact table

-- In 'Table' (fact)
FY Period = RELATED ( DateTable[FY Period] )


Add these two measures

Distinct BilledAmount per period (deduping daily repeats per employee)

Distinct Billed per Period =
VAR curPeriod = SELECTEDVALUE ( DateTable[FY Period] )
RETURN
SUMX (
-- One row per EmployeeID for the selected period
SUMMARIZE (
FILTER ( ALL ( 'Table' ), 'Table'[FY Period] = curPeriod ),
'Table'[EmployeeID],
"Amt", MAX ( 'Table'[BilledAmount] )
),
[Amt]
)


Cumulative (running) total across fiscal periods

Cumulative Distinct Billed =
VAR curPeriod = SELECTEDVALUE ( DateTable[FY Period] )
RETURN
CALCULATE (
[Distinct Billed per Period],
FILTER (
ALLSELECTED ( DateTable[FY Period] ),
DateTable[FY Period] <= curPeriod
)
)


Before all of this make sure:

Your Date table is marked as a date table, the relationship is active 1→many and Cross-filter direction is Single.

If this helps please mark my answer as Solution and drop a Kudos 🙏

AnalyticPulse
Super User
Super User

hi @grkanth81 
i am able to get cumulative sum with below formula:

Cumulative Distinct Billed =
VAR CurrentPeriod = MAX(tt[Period])
VAR UniqueBefore =
    CALCULATETABLE(
        DISTINCT(tt[BilledAmount]),
        FILTER(
            ALL(tt),
            tt[Period] <= CurrentPeriod
        )
    )
RETURN
SUMX(UniqueBefore, [BilledAmount])

adjust the attribute names and check if this serves your purpose.

 

My Work:
Analytic Pulse Blog 
Docynx Productivity Tools 




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.