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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jay_patel
Helper IV
Helper IV

Looking For a measure to calculate sum for upto selected month

Hello All

 

I want a measure where i am calculating (Net Sales) and if I filter "june-2021" then the values will be only for June month. But I want to calculate Net sales from first month of the table till selected month (june) . For example table has a value from jan to june and if i select march then the Net sales should be from Jan to March.

 

Thanks in advance

 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi @jay_patel ;  

You could create a new table as a slicer, and then create a measure to calculate Net sales by the following formula:

1.create a new slicer table and create a column:

 

slicer = SUMMARIZE('Table',[Date])
year-month = FORMAT([Date],"YYYY MMM")

 

2.create a sum measure:

 

sum =
CALCULATE (
    SUM ( [Net sales] ),
    FILTER (
        ALL ( 'Table' ),
        YEAR ( [Date] ) = YEAR ( MAX ( 'slicer'[Date] ) )
            && MONTH ( [Date] ) <= MONTH ( MAX ( 'slicer'[Date] ) )
    )
)

 

The final output is shown below:  

v-yalanwu-msft_0-1623056057326.jpegv-yalanwu-msft_1-1623056057329.png

 

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Madhura29
Frequent Visitor

You can use Running Total Measure for cummulative sum and a slicer to select a Month. 

Measure for Running Total - 

Running total selected = CALCULATE([Total Sales],FILTER(ALLSELECTED('Data sets'), 'Data sets'[Date ] <= MAX('Data sets'[Date ])))
v-yalanwu-msft
Community Support
Community Support

Hi @jay_patel ;  

You could create a new table as a slicer, and then create a measure to calculate Net sales by the following formula:

1.create a new slicer table and create a column:

 

slicer = SUMMARIZE('Table',[Date])
year-month = FORMAT([Date],"YYYY MMM")

 

2.create a sum measure:

 

sum =
CALCULATE (
    SUM ( [Net sales] ),
    FILTER (
        ALL ( 'Table' ),
        YEAR ( [Date] ) = YEAR ( MAX ( 'slicer'[Date] ) )
            && MONTH ( [Date] ) <= MONTH ( MAX ( 'slicer'[Date] ) )
    )
)

 

The final output is shown below:  

v-yalanwu-msft_0-1623056057326.jpegv-yalanwu-msft_1-1623056057329.png

 

Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@jay_patel , use time intelligence with date table

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))

 

 

In case you need a trend refer

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.