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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Duration between statuses

Good day All,

 

I have a bit of a conundrum. I have data as per below

 

JeremyJansevr_0-1676273306327.png

 

I would like to calculate the duration that a specific "issue_id" has spent in a status (from_string and to_string). I would like the end user to be able to choose any "from_ string" and any "to_string" and then see the result as a sum value of all the statuses in between. What would the best way be to do this?

 

Edit: Typo

 

4 REPLIES 4
Anonymous
Not applicable

Hi  @Anonymous ,

 

Here are the steps you can follow:

1. Create calculated table.

From_Table =
DISTINCT('Table'[from_string])

vyangliumsft_0-1676873103016.png

To_Table =
DISTINCT('Table'[to_string])

vyangliumsft_1-1676873103017.png

2. Create measure.

from_string_measure =
var _from=SELECTEDVALUE('From_Table'[from_string])
var _to=SELECTEDVALUE('To_Table'[to_string])
var _column=SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[isuue_id]=MAX('Table'[isuue_id])),"1",[from_string])
return
IF(
    _from in _column ,_from,"N/A"
)
to_string_measure =
var _from=SELECTEDVALUE('From_Table'[from_string])
var _to=SELECTEDVALUE('To_Table'[to_string])
var _column=SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[isuue_id]=MAX('Table'[isuue_id])),"1",[to_string])
return
IF(
    _to in _column ,_to,"N/A"
)
Measure =
var _from=SELECTEDVALUE('From_Table'[from_string])
var _to=SELECTEDVALUE('To_Table'[to_string])
var _column1=SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[isuue_id]=MAX('Table'[isuue_id])),"1",[from_string])
var _column2=SELECTCOLUMNS(FILTER(ALL('Table'),'Table'[isuue_id]=MAX('Table'[isuue_id])),"1",[to_string])
var _mindatefrom=
Minx(FILTER(ALL('Table'),'Table'[from_string]=_from),[Create])
var _maxdateto=
MAXX(FILTER(ALL('Table'),'Table'[to_string]=_to),[Create])
return
IF(_from in _column1 && _to in _column2,
SUMX(FILTER(ALL('Table'),
    'Table'[Create]>=_mindatefrom&&'Table'[Create]<=_maxdateto),[Duration_Days]
    ),
    "N/A"
)

3. Result:

From_string – Idea Logged

To_string – Rejected

vyangliumsft_2-1676873103018.png

From_string – Idea Logged

To_string – In IT Backlog

vyangliumsft_3-1676873103019.png

 

Best Regards,

Liu Yang

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

Anonymous
Not applicable

Thank you Liu Yang,

 

I tried something similar over the weekend. I created two seperate tables "To" and "From" in Power Query. I then link the two tables with one direction to the fact table and created measure where I am looking for the earliest From date and the Latest To date. It is working, but the calculation takes a while.

 

Your solution seems a bit more elegant and efficient. I am going to give it a try.

AnkitKukreja
Super User
Super User

Hi @Anonymous 

 

Not sure if I'm missing something, but I can't see "from_status" and "to_status". Also, can you share your sample file with expected solution so I can try to help with the solution.

 

 

For Power BI trainings or support dm or reach out to me on LinkedIn.
If my response has successfully addressed your question or concern, I kindly request that you mark this post as resolved. Additionally, if you found my assistance helpful, a thumbs-up would be greatly appreciated.

Thanks,
Ankit Kukreja
www.linkedin.com/in/ankit-kukreja1904
Anonymous
Not applicable

Hi AnkitKukreja,

 

Sorry about the Typo, it should have been "from_string" and "to_string". I am not sure how to share files on here.

 

Below is a better example with possible outcomes I am looking for. The "Duration_Days" column I already managed to add in Power Query and calculates correctly. Whether this is the correct way or not I am not sure.

 

JeremyJansevr_0-1676286633034.png

 

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.