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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
GoingIncognito
Advocate III
Advocate III

Using distinct in iterator function?

Hi.

 

I want to count median time for each item to process through. I've a fact table that has items as one column, and creation date as one column and finally resolution date as third column. 
So I wrote the following: medianx(table, table[item], datediff(creation, resolution, day)). But as this is a fact table each item has several rows, how do I insert distinct(table[item]) into this? Tried few approaches to no avail. 

Thank you.

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

@GoingIncognito 

1. Place Label in  a table visual

2. Place this measure in the table:

Measure =
MEDIANX (
    DISTINCT ( Table1[Key] ),
    VAR createdT_ = CALCULATE ( MIN ( Table1[Created] ) )
    VAR solvedT_ = CALCULATE ( MAX ( Table1[Resolution] ) )
    RETURN
        solvedT_ - createdT_ //Time diff in days...
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

8 REPLIES 8
AlB
Community Champion
Community Champion

@GoingIncognito 

1. Place Label in  a table visual

2. Place this measure in the table:

Measure =
MEDIANX (
    DISTINCT ( Table1[Key] ),
    VAR createdT_ = CALCULATE ( MIN ( Table1[Created] ) )
    VAR solvedT_ = CALCULATE ( MAX ( Table1[Resolution] ) )
    RETURN
        solvedT_ - createdT_ //Time diff in days...
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

GoingIncognito
Advocate III
Advocate III

Oh, I thought I had it figured out. I guess I didn't. 
My data simplified is following:

GoingIncognito_0-1606914974463.png

Each key can have several rows. I'm interested averages time from created to resolution. So I'm not interested on updated column, but because it exists there is several rows for each key. And I prefer using median instead of average because the data isn't nearly normal distributed. In my report I'll group keys by labels, so I can show how time to resolution differs for each label.

 

Thank you!

Hi, @GoingIncognito 

 

I'd love to help you, but I really don't know what your calculation logic,Could you please share your desired result?So we can help you soon.

 

Best Regards

Janey Guo

 

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

If my intensios are this difficult to fathom then I must be really off the target. 
Okay, let's say that I want for each distinct label (please see the picture in my previous post) a median of how much all the tickets under that label took time from created to resolution.

E.g. let's say that under "Utilities label" I had only two tickets. First ticket took 7 days to be completed and second took 5 days.  As we have no clear midmost number we have to calculate it: (5+7)/2 = 6. And I want to do this for all the labels in my data. I thought iterator would be nice, because it would show the time from created to resolution on drill-down (this number of course wouldn't be a median but the value itself).

Am I still not making any sense?
And thanks for the help!

v-janeyg-msft
Community Support
Community Support

Hi, @GoingIncognito 

 

It’s my pleasure to answer for you.

According to your description,you want to count median time,but medianx function only count the number in the column,It seems somewhat contradictory.

Can you provide some sample data and expected results for reference in order to quickly solve your problem?

 

Best Regards

Janey Guo

 

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

amitchandak
Super User
Super User

@GoingIncognito , Try like , if this can work

medianx(values(table[item]), datediff(min(Table[creation]), max(Table[resolution]), day))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

I get an error: A table of multiple values was supplied where a single value was expected.

AlB
Community Champion
Community Champion

Hi @GoingIncognito 

Plase show sample data and an example with expected result that helps clarify the requirements. Otherwise we'll waste time making assumptions about what you actually need

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.