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
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
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.