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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
NewbieJono
Post Patron
Post Patron

Calculate volume for max month

is there any method to calculate the total volume for the whole month based on the last date in a table

 

e.g

 

if the data for april went up to 27th April. i would like to calculate the volume for all dates in april.

1 ACCEPTED SOLUTION
Ritaf1983
Super User
Super User

Hi @NewbieJono 
You can use something like :

last month sales =
VAR
max_Date =
CALCULATE(MAX('orders'[Order Date]),REMOVEFILTERS('Calendar'))
RETURN
CALCULATE([total_sales],YEAR('Calendar'[Date])= year(max_Date) && month('Calendar'[Date])= month(max_Date))
Ritaf1983_0-1714229883143.png

the pbix is attached 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
Ritaf1983
Super User
Super User

Hi @NewbieJono 
You can use something like :

last month sales =
VAR
max_Date =
CALCULATE(MAX('orders'[Order Date]),REMOVEFILTERS('Calendar'))
RETURN
CALCULATE([total_sales],YEAR('Calendar'[Date])= year(max_Date) && month('Calendar'[Date])= month(max_Date))
Ritaf1983_0-1714229883143.png

the pbix is attached 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly.

 

Alex87
Solution Supplier
Solution Supplier

Hello @NewbieJono ,

Please try the following DAX measure:

TotalVolumeForMonth = 

VAR _LastDateInMonth = MAX('Table'[Date])  // Assuming 'Date' is your date column and it is properly formatted as a date.
VAR _StartOfMonth = STARTOFMONTH('Table'[Date])
VAR _Result = 
CALCULATE(
    SUM('Table'[Volume]),  
    'Table'[Date] >= _StartOfMonth && 'Table'[Date] <= _LastDateInMonth
)
RETURN
_Result

 If it satisfies your needs, please do not forget to mark my reply as the solution. Cheers!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.