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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
brankocareer
Helper I
Helper I

Very Complex Accumulated Values with Time

Hi all,

I have a table including columns [Position ID],[Modified Date],[FTE Count]. What I need is the accumulated distinct count of  [Position ID] with time. The logic is as follow:

[Position ID] A, have 6 [FTE Count] records  (0,0,0,0,0,1) , A is counted since the first 1.
[Position ID] B have 6 records of FTE, (0,1,0,0,0,0) , B is counted at the time of first 1, and since following 0, B is not counted.
After all, if at a time point [FTE Count]=0,the [Position ID] will be not counted; if at a time point [FTE Count]=1, the [Position ID] will be counted.

I spent a lot of time to write the measure, but it is still not right.

My incorrect meassure:
Accumulated Position Test =
VAR CurrentDate = MAX('Energy_FTE_History'[Modified Date])
RETURN
    CALCULATE(
        DISTINCTCOUNT('Energy_FTE_History'[Position ID]),
        FILTER(
            ALL('Energy_FTE_History'),
            'Energy_FTE_History'[Modified Date] <= CurrentDate &&
            'Energy_FTE_History'[FTE Count] = 1
        )
    )

 

I really need help!

 

Thank you in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @brankocareer 

 

I checked your code and the problem may occur in the judgment of cumulative conditions. The following is the solution I provided:

 

Here's some dummy data

 

"Energy_FTE_History"

vnuocmsft_0-1708930501542.png

 

The modified code is as follows.

 

Accumulated Position Test = 
VAR CurrentID = MAX('Energy_FTE_History'[Position ID])
RETURN
    CALCULATE(
        DISTINCTCOUNT('Energy_FTE_History'[Position ID]),
        FILTER(
            ALL('Energy_FTE_History'),
            'Energy_FTE_History'[Position ID] <= CurrentID &&
            'Energy_FTE_History'[FTE Count] = 1
        )
    )

 

Filter out FTE Count of 0.

 

vnuocmsft_1-1708930662154.png

 

Here is the result.

vnuocmsft_2-1708930734232.png

 

Regards,

Nono 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

2 REPLIES 2
Anonymous
Not applicable

Hi @brankocareer 

 

I checked your code and the problem may occur in the judgment of cumulative conditions. The following is the solution I provided:

 

Here's some dummy data

 

"Energy_FTE_History"

vnuocmsft_0-1708930501542.png

 

The modified code is as follows.

 

Accumulated Position Test = 
VAR CurrentID = MAX('Energy_FTE_History'[Position ID])
RETURN
    CALCULATE(
        DISTINCTCOUNT('Energy_FTE_History'[Position ID]),
        FILTER(
            ALL('Energy_FTE_History'),
            'Energy_FTE_History'[Position ID] <= CurrentID &&
            'Energy_FTE_History'[FTE Count] = 1
        )
    )

 

Filter out FTE Count of 0.

 

vnuocmsft_1-1708930662154.png

 

Here is the result.

vnuocmsft_2-1708930734232.png

 

Regards,

Nono Chen

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

 

 

 

Greg_Deckler
Community Champion
Community Champion

@brankocareer 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.



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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