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
agustiny
Frequent Visitor

Calculating median of time by group

Hi.

 

Im having trouble in calculating the median of a column in my proyect. I can't get it to work (no result).

 

Well, the thing it's like this.

I have 2 tables, one it's a calendar table and the other one it's my data table. They have a one to many relation.

 

agustiny_0-1639147276473.png

 

I want to get the median of a column, group by date (month date) like i have my other measures, but i cant get it to work.

The values that i want to get the median, are expresed in seconds.

 

So, what i want should be something like this:

agustiny_0-1639149054638.png

And it should be able to filter by Consulta1[CANAL]

 

I tried creating a measure in many ways,

 

median (time_total) = MEDIAN(tablaPortabilidades[TPO_TOTAL])

 

median (time_total) = MEDIANX(tablaPortabilidades, tablaPortabilidades[TPO_ACEPT])

 

I also tried creating a measure that sums [TPO_ACEPT] and then creating a median of this sum, but same result.

The result:

agustiny_1-1639147847010.png

 

Can someone give me a hand?

 

I don't know how to upload my .pbix here so i upload it to my drive.

.pbix 

Here the data was imported, but im usind a direct query connection.

 

Pd: In the pbix the Consulta1 is the same as tablaPortabilidades

 

Thanks!

 

1 ACCEPTED SOLUTION
bcdobbs
Super User
Super User

Hi, 
Are you creating it as a measure? If so your dax is ok and seems to work with the demo you sent:

bcdobbs_0-1639151183601.png

Here the measure has just been dropped into the values box of the matrix.


The only thing I can think is you might be trying to create a calculated column? If so MEDIAN isn't supported over direct query MEDIAN function (DAX) - DAX | Microsoft Docs



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

5 REPLIES 5
bcdobbs
Super User
Super User

Hi, 
Are you creating it as a measure? If so your dax is ok and seems to work with the demo you sent:

bcdobbs_0-1639151183601.png

Here the measure has just been dropped into the values box of the matrix.


The only thing I can think is you might be trying to create a calculated column? If so MEDIAN isn't supported over direct query MEDIAN function (DAX) - DAX | Microsoft Docs



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

I supposed it was something related with direct query. Is there a way to something like this with direct query? I can't import the whole data set because it's huge.

I tried doing it on sql but then i can't filter it.

My understanding is it should work if you just use it in a measure? Have you tried that?



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Yes, it actually works but only if a import the data. My issue is that i have to work with direct query, yes or yes. So, im looking for a way of doing the same but with direct q.

Can you expand the error details on the visual and send it over?

 

I've just setup an example using direct query to contoso in SQL and can make a MEDIAN measure work so wondering if there is another issue.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

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.

Top Solution Authors