Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers!
Enter the sweepstakes now!Preparing for a certification exam? Ask exam experts all your questions on May 15th. Register now.
Hi,
I've started with Power BI a week ago. I found that was the perfect tool for what i was asked for.
I've been chosen to get the time measures of the processes of my company. The metric chosen has been the Lead Time. For each item there is a Lead Time.
Each item must be categorized in a product catalog. Then the metricts will be shown by product:
The only metric that I havent been able to calculate with Power BI desktop is LT_average_max. I want to get the value of the average of the month with the highest (or lowest) average. At the moment I am using and aux matrix summarizing the averages by product and by month, and them I've to copy all manually to anothe table for the presentations (very arcaic).
Taking in account my researchs, I guess that the optimal way to get this value is by using a measure. But at the moment I can only write very simple functions and I'm not ready to solve this problem.
Thank you in advanced for trying to help me.
P.D. This is my first post. If you have found points on which I can improve, I would be grateful if you could point them out to me .
Solved! Go to Solution.
@Anonymous can you try the above?
avgByProdMaxYear =
CALCULATE (
AVERAGE ( 'Sample'[LT] ),
VAR _base =
GROUPBY (
'Sample',
'Sample'[Product],
'Sample'[Year],
"avg", AVERAGEX ( CURRENTGROUP (), 'Sample'[LT] )
)
VAR _rank =
SUMMARIZE (
FILTER (
ADDCOLUMNS (
_base,
"rank", RANKX ( FILTER ( _base, [Product] = EARLIER ( [Product] ) ), [avg],, DESC )
),
[rank] = 1
),
'Sample'[Product],
'Sample'[Year]
)
RETURN
_rank
)
@Anonymous please refer to the attached pbix
@Anonymous can you try the above?
avgByProdMaxYear =
CALCULATE (
AVERAGE ( 'Sample'[LT] ),
VAR _base =
GROUPBY (
'Sample',
'Sample'[Product],
'Sample'[Year],
"avg", AVERAGEX ( CURRENTGROUP (), 'Sample'[LT] )
)
VAR _rank =
SUMMARIZE (
FILTER (
ADDCOLUMNS (
_base,
"rank", RANKX ( FILTER ( _base, [Product] = EARLIER ( [Product] ) ), [avg],, DESC )
),
[rank] = 1
),
'Sample'[Product],
'Sample'[Year]
)
RETURN
_rank
)
Looks like it works. Thank you very much.
@Anonymous while this works, I want to leave you with a more elegant 1 line measure. Pbix is attached.
_top1Average =
CALCULATE (
[average],
KEEPFILTERS ( TOPN ( 1, ALLSELECTED ( Sample_data[Year] ), [average], DESC ) )
)
Thank you but this second solution does not work for me. I will try it later when I'll get a bertter understanding of DAX and M.
The error that I get is that there is no column [average].
@Anonymous please refer to the attached pbix
Now it works, I didn't know that [average] were a measure. This shows exactly what I'was looking for.
Thanks
Hi @Anonymous
Something like
LT_Average_max =
MAXX(
VALUES(Table[month]),
AVERAGE(Table[Lead Time])
)
Hi @PaulOlding.
This solution gives me the same solution as the annual average. The measure that I am looking for should calculate the LT for each month and provide the maximum value. In the table attached, LT_Average_min = 18,92 (I need the lowest btw, but it does not affect).
Thank you in any case.
I think to help any further I would need some example data and the result you're expecting from that.
I've made a sample in which three tables are shown.
You can access the table through this link: data example.xlsx
The pasword is:
Power_BI
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
18 | |
13 | |
11 | |
10 | |
9 |