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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
DazzaG
New Member

assistance with DAX code please

hi team, im fairly new to power BI and am helping my colleague with some reporting.  We are using a report created by someone else who has since left the organisation. The  report displays some averages using DAX query but the results appear to be very generous or low. I believe that something in the DAX formular or the way the data is displayed isnt right and would appreciate some assistance trying to work through it.

 

One example is Average Manger approval time which the result is 00:01:49 . Looking at the data [Manager Approval] it should be alot highter. A snippet of the [Manager Approval] data is below. Thats not all the data just a sample

 

DazzaG_0-1692149990941.png

 

 

 the DAX query is 

 

Avg Manager Approval Time =

VAR DecimalMinutes = AVERAGE(TimeIntelligence[Manager Approval])

VAR Duration = DecimalMinutes * 60

VAR Hours = INT(DIVIDE(Duration,3600,0))

VAR Minutes = INT(DIVIDE(MOD( Duration - ( Hours * 3600 ),3600),60,0))

VAR Seconds = ROUNDUP(MOD ( MOD( Duration - ( Hours * 3600 ),3600 ), 60 ),0)

VAR H = IF (LEN ( Hours ) = 1, CONCATENATE ( "0", Hours ), CONCATENATE ( "", Hours ))

VAR M = IF (LEN ( Minutes ) = 1, CONCATENATE ( "0", Minutes ), CONCATENATE ( "", Minutes ))

VAR S = IF (LEN ( Seconds ) = 1, CONCATENATE ( "0", Seconds ), CONCATENATE ( "", Seconds ))

RETURN

IFERROR(
    IF (DecimalMinutes>0,
    H & ":" & M & ":" & S,
    "0:00"),
    "Error")

 

thanks in advance

1 REPLY 1
mickey64
Super User
Super User

I think this DAX formular is wrong.

VAR DecimalMinutes = AVERAGE(TimeIntelligence[Manager Approval])

 

[Manager Approval] shows hh:mm.

In this formular, 6 hours is 06:00 (Decimal: 0.25). 

 

I didn't understand what the person left the organisation wanted to do.

Insted I show a simple formular.

 

Avg Manager Approval Time = AVERAGE([Manager Approval])

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.