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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
harshadrokade
Post Partisan
Post Partisan

Days spent in stage

Hi sir/mam,

 

I have below data and I want to generate 'Days spent on the Oldstage' column in power bi. I have also given referance column to know how I calculated this column in excel. Basically I want to know how many days were spent at a stage befor moving to a new stage. I want to follow the sequence of the stages as A>B>C>D.

 

IdMovement start DateOldStageNewStageDays spent on the OldstageFormula for referance
128-10-20 15:32BC7.587199074C date - B date
128-10-20 15:29AB0.001886574B date - A date
105-11-20 5:38CD3D date - C date
108-11-20 5:38DENANA
228-11-20 15:29AB1B date - A date
229-11-20 15:29BC10C date - B date
209-12-20 15:29CD2D date - C date
211-12-20 15:29DENANA
4 REPLIES 4
Fowmy
Super User
Super User

@harshadrokade 

Create the following calculated column in your table:?

Days Spent = 

VAR __FromStage = Stages[OldStage]
VAR __TOStage = Stages[NewStage]
VAR __FromTime = 
    CALCULATE(
        MAX( Stages[Movement start Date] ) , 
        Stages[OldStage] = __TOStage,
        ALLEXCEPT( Stages , Stages[Id] )
    )
VAR __Result= 
         DATEDIFF( Stages[Movement start Date] , __FromTime , DAY ) 
RETURN
    __Result
        

Fowmy_0-1701595238316.png

 





Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

danextian
Super User
Super User

Hi @harshadrokade ,

 

For row 2, 8-10-20 15:29 + 0.001886574 = 28-10-2020 15:31 but this  datetime is not anywhere in your sample data.  And is this by Id?










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thanks @danextian for looking into this.

 

I have this datetime, its actually 28-10-20 15:32.Ignore the last decimaldue to rounding off..

 

It is the start day/time of Stage B. When I compare this date with start day/time of Stage A (28-10-20 15:29), I get value as 0.001886574.

 

 

Hi @harshadrokade 

Days spent = 
CALCULATE (
    MAX ( 'Table'[Movement start Date] ),
    FILTER (
       'Table', 
        'Table'[OldStage] = EARLIER ( 'Table'[NewStage] ) && 'Table'[Id] = EARLIER( 'Table'[Id])
    )
) - 'Table'[Movement start Date]









Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

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