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
myfirstdax
New Member

CALCULATE AVERAGE TIME IN THE SAME DAY

Hi all, i need your help so please! I tried a lot to find out a way but i did't manage to...so here i am.

The problem is very simple tough. With DAX i would like to find a way to calculate the average time in the same day as in the table below (AVERAGETIME_IN DAY 😞

 

HELP IN ADVANCE!

average_time.png

 

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

HI @myfirstdax

 

Try

 

=
CALCULATE (
    AVERAGE ( TableName[Time] ),
    ALLEXCEPT ( TableName, TableName[DAY] )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

10 REPLIES 10
Phil_Seamark
Employee
Employee

Hi @myfirstdax

 

This calculated column is one way.  Can easily turn in a measure if you need as well

 

AVERATETIME_IN DAY = 
    AVERAGEX(
        FILTER(
            'Table',
            'Table'[Day] = EARLIER('Table'[Day])
            ),
            [Time])

 

if you want a measure then this is the code

 

Measure  = 
	CALCULATE(
		AVERAGE('Table'[Time]),
		FILTER(
			ALLSELECTED('Table'),
			'Table'[Day] = MAX('Table'[Day]))
			)

 

image.png


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

I will use this in the next formulas .. I enjoyed very much this variant!

Hi all, please help me! I tried to find out a way to solve it but i can't without your help. The problem is very simple though. I would like to calculate the column "AVERAGE_TIME" as in the table below with dax formulas:

 

THANKS IN ADVANCE

 

   to find with DAX!!!
DAYSupplierTimeAVERAGETIME_IN DAY
01/01/2018Supplier 41011
01/01/2018Supplier 11211
01/01/2018Supplier 11111
04/01/2018Supplier 21526
04/01/2018Supplier 31726
04/01/2018Supplier 4126
04/01/2018Supplier 52326
02/01/2018Supplier 67454
02/01/2018Supplier 33454

 

 

Hi @myfirstdax

 

There are a couple of replies to this in your other post,


To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

@myfirstdax

 

Try this

 

=
CALCULATE (
    AVERAGE ( TableName[Time] ),
    FILTER ( ALLEXCEPT ( TableName, TableName[DAY] ), TableName[Time] > 0 )
)

 

 


Regards
Zubair

Please try my custom visuals

@myfirstdax

 

for the learning purposes you can also leverage @Phil_Seamark  approach by adding a second conditional to the filter with AND  "&& (double ampersand)"operator. This pattern in very common.


=
CALCULATE (
    AVERAGE ( 'Table'[Time] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[Day] = MAX ( 'Table'[Day] )
            && 'Table'[Time] > 0
    )
)

 

N -

 

@Zubair_Muhammad and @nickchobotar thank you very much for you advice. Smiley Wink

 

Also for educational purpose the solution runs correctly

 

Good day all and thank your for supoort to community

Zubair_Muhammad
Community Champion
Community Champion

HI @myfirstdax

 

Try

 

=
CALCULATE (
    AVERAGE ( TableName[Time] ),
    ALLEXCEPT ( TableName, TableName[DAY] )
)

Regards
Zubair

Please try my custom visuals

hi, another question if you want to help me again..i would calculate the average excluding also the zero..how i could this? surely with filter but i cant' manage to nest them correctly.. thanks!!

@Phil_Seamark @Zubair_Muhammad

THNAK YOU VERY MUCH! I DIDN't think to allexcept 🙂

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.