Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Please ask, I want to make a table to find the cumulative average tonnage based on date and month in Power BI, like the following picture:
and this is the dax formula I can't get:
Release Average = CALCULATE(
AVERAGE(DataRelease[TONAGE]),
DataRelease[Date] = EARLIER(DataRelease[Date]))
Solved! Go to Solution.
Hi @Bambang_Sono ,
Thanks for ryan_mayu and bhanu_gautam reply.
You can also try the follwing code to create a calculate column
Avg per days =
VAR CurrentDate = 'Table'[Date]
VAR CurrentMonth = 'Table'[Month]
VAR CurrentTonase = 'Table'[Tonase]
VAR DaysUntilCurrentDate = COUNTROWS(FILTER('Table', 'Table'[Month] = CurrentMonth && 'Table'[Date] <= CurrentDate))
VAR CumulativeTonase =
CALCULATE(
SUM('Table'[Tonase]),
FILTER(
'Table',
'Table'[Month] = CurrentMonth &&
'Table'[Date] <= CurrentDate
)
)
RETURN
CumulativeTonase / DaysUntilCurrentDate
Final output
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi @Bambang_Sono ,
Thanks for ryan_mayu and bhanu_gautam reply.
You can also try the follwing code to create a calculate column
Avg per days =
VAR CurrentDate = 'Table'[Date]
VAR CurrentMonth = 'Table'[Month]
VAR CurrentTonase = 'Table'[Tonase]
VAR DaysUntilCurrentDate = COUNTROWS(FILTER('Table', 'Table'[Month] = CurrentMonth && 'Table'[Date] <= CurrentDate))
VAR CumulativeTonase =
CALCULATE(
SUM('Table'[Tonase]),
FILTER(
'Table',
'Table'[Month] = CurrentMonth &&
'Table'[Date] <= CurrentDate
)
)
RETURN
CumulativeTonase / DaysUntilCurrentDate
Final output
Best regards,
Albert He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
you can try this
pls see the attachment below
Proud to be a Super User!
@Bambang_Sono , Try using
DAX
Release Average =
VAR CurrentDate = DataRelease[Date]
RETURN
CALCULATE(
AVERAGE(DataRelease[TONAGE]),
FILTER(
ALL(DataRelease),
DataRelease[Date] <= CurrentDate
)
)
Proud to be a Super User! |
|
What if it's combined with the summarize function?
example of my dax formula:
Average Release =
VAR CurrentDate = DataRelease[Date].[Date]
RETURN
CALCULATE(
AVERAGEX(DataRelease[TONAGE]),
SUMMARIZE(
FILTER(
ALL(DataRelease),DataRelease[Date].[Date] <= CurrentDate)
)
User | Count |
---|---|
84 | |
78 | |
69 | |
46 | |
42 |
User | Count |
---|---|
106 | |
50 | |
49 | |
40 | |
40 |