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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
shreep1
Helper III
Helper III

AVERAGEX Function PowerBI

Hello @Amit@Greg , @tamerj1 , @lbendlin 

 

@amitchandak , @olgad , @Sahir_Maharaj , @FreemanZ , @tamerj1 , @Greg_Deckler 

 

I was able to get the Average Jobs Per Hour Trend for each of the hour by writing this DAX code:

 

DAX Date Custom = AVERAGEX(VALUES(T_Cycle_Takt_Time_Detail[Op_Complete_Date].[Date]),CALCULATE(DISTINCTCOUNTNOBLANK('T_Cycle_Takt_Time_Detail'[Job_No]),'T_Cycle_Takt_Time_Detail'[Workcenter_Code] IN {"R0"}))
 
The code above displays this chart below:
 
shreep1_2-1684521097834.png

 

X-axis and Y-axis is displayed like this in the above chart:

shreep1_5-1684522037083.png

 

 Now, I am trying to find the Average Jobs per Hour for the month of April where I should be getting a value of 3.39 based on the trend line above. 

 

shreep1_3-1684521487825.png

 

The code I wrote for the above display was:

 

DAX Date Custom Month = (AVERAGEX(VALUES(T_Cycle_Takt_Time_Detail[Op_Complete_Date].[Day]),CALCULATE(DISTINCTCOUNTNOBLANK('T_Cycle_Takt_Time_Detail'[Job_No]),'T_Cycle_Takt_Time_Detail'[Workcenter_Code] IN {"R0"})))

 

 DAX code above represent the Y-axis. 

 

X-axis is the Op_Complete_Date by Month hierarchy.

 

shreep1_4-1684521847436.png

 

As you can clearly see, I am getting a value of Average Jobs Per Hour for the month of April as 65 which is clearly wrong and it should be 3.39. 

 

Can you please help me solve this problem by suggesting either fixing my DAX code, writing a new DAX code or using something else on the X-axis and Y-axis?

 

Thanks


 

 


 

 
 
 

 

 

3 REPLIES 3
shreep1
Helper III
Helper III

Hello @Amit@Greg , @tamerj1 , @lbendlin 

 

@amitchandak , @olgad , @Sahir_Maharaj , @FreemanZ , @tamerj1 , @Greg_Deckler 

 

 @danextian @Ashish_Mathur @Jihwan_Kim @johnt75 @Ritaf1983 

 

On the 2nd graph of Monthly Trend even if I write the DAX code by mentioning: T_Cycle_Takt_Time_Detail[Op_Complete_Date].[Date]

 

DAX Date Custom = AVERAGEX(VALUES(T_Cycle_Takt_Time_Detail[Op_Complete_Date].[Date]),CALCULATE(DISTINCTCOUNTNOBLANK('T_Cycle_Takt_Time_Detail'[Job_No]),'T_Cycle_Takt_Time_Detail'[Workcenter_Code] IN {"3-0030-R0"}))

 

I still get the Average for Month of April as 65. 

 

Even if I write this DAX code by including [Day] inside of a T_Cycle_Takt_Time_Detail[Op_Complete_Date].[Day]

 

DAX Date Custom Month = (AVERAGEX(VALUES(T_Cycle_Takt_Time_Detail[Op_Complete_Date].[Day]),CALCULATE(DISTINCTCOUNTNOBLANK('T_Cycle_Takt_Time_Detail'[Job_No]),'T_Cycle_Takt_Time_Detail'[Workcenter_Code] IN {"R0"})))

 

I still get the Monthly Average of 65. 

 

If I write something like this:

 

DAX Date Custom = AVERAGEX(VALUES(T_Cycle_Takt_Time_Detail[Op_Complete_Date].[Month]),CALCULATE(DISTINCTCOUNTNOBLANK('T_Cycle_Takt_Time_Detail'[Job_No]),'T_Cycle_Takt_Time_Detail'[Workcenter_Code] IN {"3-0030-R0"}))

 

I get a Monthly Average of 1888 which is even more wrong.

 

Not sure what DAX code to write to find the Average Jobs Per Hour for the month of April? 

 

 

 

Hi,

Share some data, explain the question and show the expected result.


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

Hello @Ashish_Mathur 

 

The main question is how to find the Average Count of Distinct Jobs Per Hour for each of the hours in the X-axis starting from 0, 1, 2,..all the way to 23, filtered by date. Y-axis is the Distinct Count of Jobs.

Here is how the sample dataset looks like:

 

shreep1_0-1684784298724.png

 

When I try to find the Average Count of Distinct Jobs Per Hour for each of the hours filtered by different date ranges, I am not getting correct answer. For example, for the month of April, I am getting answers like 65 or 1888 which does not make sense. I should get something like 3.5 etc..

 

Do you have any idea what DAX code shall I write to fix this issue?

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.