March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hi All,
I have a table like the following:
Month | Cost Centre | Pay Period Number |
1/7/21 | XX1 | 1 |
1/7/21 | XX1 | 2 |
1/7/21 | XX1 | 3 |
1/8/21 | XX1 | 4 |
1/8/21 | XX1 | 5 |
1/9/21 | XX1 | 6 |
I want to create either a measure that basically counts the rows based on month and summarises the date by month.
i.e. for example, for Cost Centre XX1 in the month of 1/7/21, there are 3 pay periods so i want it to return 3.
For 1/8/21, there are 2 pay periods, so i want to be able to return 2.
Does anyone know how i can do this?
thank you!
Solved! Go to Solution.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi,
I am not sure if I understood your question correctly, but please check the below picture and the measure.
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi @Jihwan_Kim ,
Thanks for that. I basically need to sum the values for any given month and then based on the row count, i need to divide the value to get an average.
Result will be displayed in a card.
For example, for the below, i would sum up amount (5 + 34 + 2 = 41) and then 41/max no. of pay periods which in this case is 3.
This will be displayed in a card visual and it should work dyniamcally with the dimdate slicer
Month | Cost Centre | Period Number | Amount |
1/7/21 | 1 | 5 | |
1/7/21 | 2 | 34 | |
1/7/21 | 3 | 2 |
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi @Jihwan_Kim ,
Really appreciate your help. Instead of dividing by max pay period number, i need it to be the count of periods within that month. For example, in your file, 1/08/21 average should be 42/2 (2 because in the month of august, there are 2 pay periods). Similarly, for sept, it should be 45/1 since there is only 1 pay period.
Hope that makes sense
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
THANK YOU @Jihwan_Kim ! That was exactly the result i needed! appreciate it very much!
@Andrea_Jess You can use AVERAGEX for this:
AVERAGEX(VALUES(DimDate[Month]), [Measure])
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
Hi @AllisonKennedy ,
Thanks for that! I did try that but it's not giving me the right output.
Essentially, within a month, we have varying numbers of pay periods. So for Sept, we have 3 whereas in August, we only had 2. So we capture data each pay period but i need to essentially sum up values for that month and then determine how many pay periods there were and divide by that to average it.
When i use the DAX above, i'm not getting the average for some reason 😞
@Andrea_Jess Glad you solved it - here's a post on Averages that you may find helpful??? https://excelwithallison.blogspot.com/2020/09/what-does-average-mean.html
Basically, if you want to average over number of pay periods, then that needs to be the first argument in your AVERAGEX function:
Measure = AVERAGEX( Values( Table[PayPeriod] ) , [Measure to Average] )
Hope that helps you in future!
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
@Andrea_Jess This is a simple COUNT measure if you have a DimDate table:
https://excelwithallison.blogspot.com/2020/04/dimdate-what-why-and-how.html
Then relate the Date table to the Pay period in your table and create a measure that does:
Measure = COUNT(Table[Cost Centre])
Put that Measure in the Values and DimDate[Month] in the Axis of a visual.
Copying DAX from this post? Click here for a hack to quickly replace it with your own table names
Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C
I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
123 | |
85 | |
85 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |