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
Anonymous
Not applicable

Cumulative total for all previous month for category

I have a data with Year month name and month number and the information. we are using financial year format ( April - March).

My requirement is when I select in slicer month data need to get along with from April for ex: If i select August 2021 i should get the data from April till August. If I select December I should get from April till December. Please suggest.

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

Hi, @Anonymous ;

If your format is "October 2020" , you could use follows dax to change it as date format.

date = DATE(RIGHT([year-month],4),MONTH( LEFT([year-month], SEARCH(" ",[year-month]))&" 1"),1)

then you could create a table as a slicer .

slicer = VALUES('Table'[year-month])

then create a measure to calculate a sum .

sum =
VAR _select =MAX ( 'slicer'[year-month] )
VAR _sdate =
    DATE ( RIGHT ( _select, 4 ), MONTH ( LEFT ( _select, SEARCH ( " ", _select ) ) & " 1" ), 1)
RETURN
    IF (
        MONTH ( _sdate ) >= 4,
        CALCULATE (
            SUM ( [value] ),
            FILTER ( 'Table', [date] >= DATE ( YEAR ( _sdate ), 4, 1 ) && [date] <= _sdate )),
        CALCULATE (
            SUM ( [value] ),
            FILTER (
                ALL ( 'Table' ),
                [date]
                    >= DATE ( YEAR ( _select ) - 1, 4, 1 )
                    && [date] <= _sdate)))

The final output is shown below:

 

vyalanwumsft_1-1634871085603.pngvyalanwumsft_2-1634871118226.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

4 REPLIES 4
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

If your format is "October 2020" , you could use follows dax to change it as date format.

date = DATE(RIGHT([year-month],4),MONTH( LEFT([year-month], SEARCH(" ",[year-month]))&" 1"),1)

then you could create a table as a slicer .

slicer = VALUES('Table'[year-month])

then create a measure to calculate a sum .

sum =
VAR _select =MAX ( 'slicer'[year-month] )
VAR _sdate =
    DATE ( RIGHT ( _select, 4 ), MONTH ( LEFT ( _select, SEARCH ( " ", _select ) ) & " 1" ), 1)
RETURN
    IF (
        MONTH ( _sdate ) >= 4,
        CALCULATE (
            SUM ( [value] ),
            FILTER ( 'Table', [date] >= DATE ( YEAR ( _sdate ), 4, 1 ) && [date] <= _sdate )),
        CALCULATE (
            SUM ( [value] ),
            FILTER (
                ALL ( 'Table' ),
                [date]
                    >= DATE ( YEAR ( _select ) - 1, 4, 1 )
                    && [date] <= _sdate)))

The final output is shown below:

 

vyalanwumsft_1-1634871085603.pngvyalanwumsft_2-1634871118226.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

@Anonymous YTD should help

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

 

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

Anonymous
Not applicable

But I dont have a date format so could not able to do YTD

Anonymous
Not applicable

I have Only Year Month name and month number in seperated columns and I couldn't able to build a date format with this information since I dont have a date

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.