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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric 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 Specialist
Solution Specialist

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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