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
srlabhe123
Post Patron
Post Patron

Running Total Required

Hi All

I have data below

srlabhe123_0-1660834230906.png

I need Running Total of VarFlag for Employee, Date, Day , kindly help 

5 REPLIES 5
v-rongtiep-msft
Community Support
Community Support

Hi @srlabhe123 ,

Please have a try.

Create a flag column.

 

flag =
IF ( 'Table'[START TIME] = "D/O", 0, 1 )

 

Then create a column group the date.

 

minflagdate =
CALCULATE (
    MIN ( 'Table'[date] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[date] >= EARLIER ( 'Table'[date] )
            && 'Table'[flag] = 0
    )
)

 

Then create a measure to get the answer.

 

result =
VAR _1 =
    CALCULATE (
        SUM ( 'Table'[flag] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[date] <= SELECTEDVALUE ( 'Table'[date] )
                && 'Table'[minflagdate] = SELECTEDVALUE ( 'Table'[minflagdate] )
                && 'Table'[EMPLY ID] = SELECTEDVALUE ( 'Table'[EMPLY ID] )
                && 'Table'[Employee name] = SELECTEDVALUE ( 'Table'[Employee name] )
        )
    )
RETURN
    IF ( MAX ( 'Table'[flag] ) = 0, 0, _1 )

 

 

vpollymsft_0-1661222554192.png

If I have misunderstood your meaning, please provide more details with your desired output.

 

Best Regards

Community Support Team _ Polly

 

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

Greg_Deckler
Super User
Super User

@srlabhe123 So maybe something like:

Running Total Measure = 
  VAR __EmplyID = MAX('Table'[Emply ID])
  VAR __Date = MAX('Table'[Date])
  VAR __Table = FILTER(ALL('Table'), [Emply ID] = __EmplyID && [Date] <= __Date)
RETURN
  SUMX(__Table, [VarFlag])

@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Not working as showing below:

srlabhe123_0-1661264294165.png

 

Hi @srlabhe123 ,

 I don't know what the problem is. Could you please provide your pbix file without privacy information and desired output for me to test?

 

Best Regards

Community Support Team _ Polly

 

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

Its showing as below 

srlabhe123_0-1660855131221.png

While I need 1,2,3,4,5 and whenver there is 0 for "D/O " next row should restart from 1,2,3 and so on.

 

Actually I want to display the no of consecutive days an employee has worked. So if employee has value D/O is day off , then next day should start from 1, 2,3 4 and so on.

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.