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
yanivshe
Helper I
Helper I

Average number of days per state + present in chronological order

I have simple lab repair data for customer orders:

1) I want to calculate the average days by state:

image.png

2) Also, I want to present it in chronological order (the order starts as "new" -> "work" -> "revision" -> "closed")

How can I present it?

5 REPLIES 5
yanivshe
Helper I
Helper I

I added the column to my SQL source with RANK() and DATEDIFF in seconds to get the desired solution.

Thank you for each for your help with this

yanivshe
Helper I
Helper I

I added column in my SQL source with RANK() and DATEDIFF in seconds to get the desired solution.

Thanks for everyone for your help with this

Ashish_Mathur
Super User
Super User

Hi,

What does your source dataset look like?  Share that.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
danextian
Super User
Super User

Hi @yanivshe 

You may use AVERAGEX to get the desired result. Try this as a measure:

Averagex = 
AVERAGEX ( VALUES ( States[STATE] ), AVERAGE ( States[Value] ) )
 

For the sort, create a conditional column  in the query editor instead of using DAX to create a sort column. You will get an error if you sort a column by a calculated column that is dependent to the column being sorted like below.

sort error.png

 

Do something like below in the query editor.

conditional column.png










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.
mahoneypat
Employee
Employee

It looks like you already have your average cycle time.  To get them to sort in the desired order, add a calculated column to your table with a switch() formula like this:

 

Status Sort = Switch([Status], "new", 1, "work, 2, "revision", 3, "closed", 4)

 

Then highlight your Status column and choose the new columns as your Sort By Column.  This will make them show up in that order in your visuals.

 

If this works for you, please mark it as the solution.  Kudos are great too.  Please let me know if it doesn't or if any questions.
Regards,
Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.