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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Pbiuserr
Post Prodigy
Post Prodigy

Is it possible to create such barchart

Hello,

Is it possible to create such bartchart? The measure from which this needs to be calculated is not necessary now - could be Sum of Sales

Capture.PNG

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

Hi @Pbiuserr ,

 

Please create a separate Dates table and use the following measure.

 

SumValues = 
VAR CurrentYear =
    YEAR ( MAX ( Dates[Date] ) )
VAR _YTD =
    CALCULATE ( SUM ( 'Table'[Values] ), DATESYTD ( 'Calendar'[Date] ) )
VAR YearEnd =
    IF ( MAX ( 'Calendar'[Date] ) = ENDOFYEAR ( 'Calendar'[Date] ), _YTD )
RETURN
    IF (
        MAX ( 'Calendar'[Date] ) = MAX ( Dates[Date] ),
        CALCULATE (
            _YTD,
            FILTER ( 'Calendar', 'Calendar'[Date] <= MAX ( Dates[Date] ) )
        ),
        IF (
            YEAR ( MAX ( 'Calendar'[Date] ) ) >= CurrentYear - 2
                && YEAR ( MAX ( 'Calendar'[Date] ) ) < CurrentYear,
            YearEnd
        )
    )

vkkfmsft_0-1652694952514.png

vkkfmsft_1-1652694962943.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

5 REPLIES 5
v-kkf-msft
Community Support
Community Support

Hi @Pbiuserr ,

 

Please create a separate Dates table and use the following measure.

 

SumValues = 
VAR CurrentYear =
    YEAR ( MAX ( Dates[Date] ) )
VAR _YTD =
    CALCULATE ( SUM ( 'Table'[Values] ), DATESYTD ( 'Calendar'[Date] ) )
VAR YearEnd =
    IF ( MAX ( 'Calendar'[Date] ) = ENDOFYEAR ( 'Calendar'[Date] ), _YTD )
RETURN
    IF (
        MAX ( 'Calendar'[Date] ) = MAX ( Dates[Date] ),
        CALCULATE (
            _YTD,
            FILTER ( 'Calendar', 'Calendar'[Date] <= MAX ( Dates[Date] ) )
        ),
        IF (
            YEAR ( MAX ( 'Calendar'[Date] ) ) >= CurrentYear - 2
                && YEAR ( MAX ( 'Calendar'[Date] ) ) < CurrentYear,
            YearEnd
        )
    )

vkkfmsft_0-1652694952514.png

vkkfmsft_1-1652694962943.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahenkj2
Solution Sage
Solution Sage

Hello @Pbiuserr ,

 

So it is cumulative sum for each year. In 2020, you will add the total for that complete year. Similarly you will add cumulative sum for 2021 and 2022 (upto current month.

 

Then you would show this on the bar chart.

 

If I understand correct, then this is quite simple if you use a date table. Use year column of date table on x axis, it will automatically sum the total for that year.

 

Please confirm if this understanding is correct or I missed out something on your requirement.

Hi, 
Well technically you're right, however I think users (so the business) would like to see labels like Dec 2020, Dec 2021, April 2022 and thats where is becomes tough 

 

also - if user select November 2021, then 2021 value would be measured up to November (2020, 2021 and 2022) or entire year (december included) ? If only till november, how to make it measure up till end of year? Give filter in measure calculation ENDOFYEAR(Calendar[Date]) ? Slicer must be Month-Year

mahenkj2
Solution Sage
Solution Sage

Hello @Pbiuserr ,

 

Can you please elaborate a bit about x axis labels? Other than what they are, if you also add A short sample of figures, that would be helpful to understand and try a solution!

The measure I'll use is sort of cumulative, so my goal is to compare Current selection, with End of the Year for previous year and end of the year -2 from current selection

 

Labels on axis would be (considering if I choose May 2022). 

December 2020, December 2021, May 2022
is it something achieveable?

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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