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

Learning to write DAX statements

Help Please!!

I have a table named 90 days. In that table there are picking units. I want to create a new measure that will give me the average pick units for each month. There is no date table.  image.png

2 ACCEPTED SOLUTIONS
jgeddes
Super User
Super User

There are many possible ways to write DAX for an average as it will depend upon the context you require. 

The most basic way involves no DAX, just measures provide by the UI.

In a table visual, drag the Date field into the columns. PBI automatically applies Date/Time Intelligence to your date column (provided it is formatted as a date). You can then select only the month (year too if you need it). Now drag the Picking Units field into the columns. Choose average as the summerization. You should now have an average by month.

Example:

jgeddes_0-1765561021205.png

In the table it results in...

jgeddes_1-1765561049888.png

But you asked for DAX. We can write this average as 

Average1 = 
AVERAGEX('Table','Table'[Picking Units])

jgeddes_2-1765561121061.png

But you may notice the total average of 14.40. That may not be the value you are expecting to see. 14.4 is the average of all the rows in the table regardless of the month as the total row lacks a month context. (It is all months). If you were wanting the total row to display the average of the monthly averages, (20+6)/2 = 13, then we need to re-write the measure.

 

Average2 = 
AVERAGEX(
    SUMMARIZE(
        'Table',
        'Table'[Date].[Year],
        'Table'[Date].[Month],
        "__avg", 
        AVERAGEX('Table', 'Table'[Picking Units])
    ),
    [__avg]
)

In this measure we are creating a virtual table that summarizes the initial table by year and month and then calculates the average picking units for each row in the virtual table. The measure then takes the average of those rows. 

jgeddes_3-1765561399537.png

There are other ways you can calculate measures, but this should give you a decent starting point. 
Please check out the Microsoft Learn documentation to learn more. 
https://learn.microsoft.com/en-us/dax/summarize-function-dax 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





View solution in original post

danextian
Super User
Super User

Hi @kaytaylor19 

Simplify time-related/date-related calculations by using a dedicated dates table marked as a date table and is related to your fact table in  a one-to-many relationship.

danextian_0-1765615437808.png

Please see the attached pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

7 REPLIES 7
v-prasare
Community Support
Community Support

Hi @kaytaylor19,

We would like to confirm if our community members answer resolves your query or if you need further help. If you still have any questions or need more support, please feel free to let us know. We are happy to help you.

 

 

Thank you for your patience and look forward to hearing from you.
Best Regards,
Prashanth Are
MS Fabric community support

v-prasare
Community Support
Community Support

Hi @kaytaylor19,

We would like to confirm if our community members answer resolves your query or if you need further help. If you still have any questions or need more support, please feel free to let us know. We are happy to help you.

 

 

Thank you for your patience and look forward to hearing from you.
Best Regards,
Prashanth Are
MS Fabric community support

krishnakanth240
Continued Contributor
Continued Contributor

Hi @kaytaylor19 

 

Assumption

Your table 90 days has:
Date (date datatype)
Picking Units (numeric)

 

Correct & Simple Solution (Measure)
Step 1: Create a Year-Month column (optional but recommended)

Calculated column:
YearMonth =
FORMAT ( '90 days'[Date], "YYYY-MM" )


This ensures correct monthly grouping.
Step 2: Create the Average Picking Units measure
Avg Picking Units Per Month :=
AVERAGEX (
VALUES ( '90 days'[YearMonth] ),
CALCULATE ( SUM ( '90 days'[Picking Units] ) )
)

 

How this works
VALUES(YearMonth) → gets each distinct month
SUM(Picking Units) → totals per month
AVERAGEX → averages across months

danextian
Super User
Super User

Hi @kaytaylor19 

Simplify time-related/date-related calculations by using a dedicated dates table marked as a date table and is related to your fact table in  a one-to-many relationship.

danextian_0-1765615437808.png

Please see the attached pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
Ashish_Mathur
Super User
Super User

Hi,

Create a Calendar table with calculated column formulas for Year, Month name and Month number.  Sort the Month name column by the Month number.  Create a many to One relationship from the Date column of the 90 Days table to the date column of the Calendar table.  To your visual, dray Year and Month name from the Calendar table.  Write this measure

Avg = average('90 days'[picking units])

Hope this helps.

 


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

@kaytaylor19 

Use this measure 

Avg Pick Units per Month =
AVERAGEX(
SUMMARIZE(
'90 days',
YEAR('90 days'[Date]),
MONTH('90 days'[Date]),
"MonthlyTotal", SUM('90 days'[PickUnits])
),
[MonthlyTotal]
)

Pleaee mark this as an accepted solution.

jgeddes
Super User
Super User

There are many possible ways to write DAX for an average as it will depend upon the context you require. 

The most basic way involves no DAX, just measures provide by the UI.

In a table visual, drag the Date field into the columns. PBI automatically applies Date/Time Intelligence to your date column (provided it is formatted as a date). You can then select only the month (year too if you need it). Now drag the Picking Units field into the columns. Choose average as the summerization. You should now have an average by month.

Example:

jgeddes_0-1765561021205.png

In the table it results in...

jgeddes_1-1765561049888.png

But you asked for DAX. We can write this average as 

Average1 = 
AVERAGEX('Table','Table'[Picking Units])

jgeddes_2-1765561121061.png

But you may notice the total average of 14.40. That may not be the value you are expecting to see. 14.4 is the average of all the rows in the table regardless of the month as the total row lacks a month context. (It is all months). If you were wanting the total row to display the average of the monthly averages, (20+6)/2 = 13, then we need to re-write the measure.

 

Average2 = 
AVERAGEX(
    SUMMARIZE(
        'Table',
        'Table'[Date].[Year],
        'Table'[Date].[Month],
        "__avg", 
        AVERAGEX('Table', 'Table'[Picking Units])
    ),
    [__avg]
)

In this measure we are creating a virtual table that summarizes the initial table by year and month and then calculates the average picking units for each row in the virtual table. The measure then takes the average of those rows. 

jgeddes_3-1765561399537.png

There are other ways you can calculate measures, but this should give you a decent starting point. 
Please check out the Microsoft Learn documentation to learn more. 
https://learn.microsoft.com/en-us/dax/summarize-function-dax 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





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.