cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Bar Chart comparing monthly volume to Average monthly volume YTD

I need to create a bar chart that displays the current monthly total across 3 seperate categories (Category 1, 2, 3) and also displays the average monthly volume YTD for all three categories. The goal is to show how the current months volume for each category compares proportionaly to the YTD volume.

 

I'm able to create the bar chart with volume from January - May 2020 for each category but am unable to create a line showing the average YTD volume for each category due to the monthly filter in the bar chart. Do I need to use DAX to overcome this issue? Would appreciate any help?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Bar Chart comparing monthly volume to Average monthly volume YTD

Hi,

 

Please try these measures:

Current Month = 
IF (
    MONTH ( MAX ( 'Table'[Date] ) ) = MONTH ( TODAY () ),
    SUM ( 'Table'[Values] )
)
YTD = 
VAR a =
    SUMMARIZE (
        ALLSELECTED ( 'Table' ),
        'Table'[Date],
        'Table'[Category],
        "YTD", CALCULATE (
            SUM ( 'Table'[Values] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Category] IN FILTERS ( 'Table'[Category] )
                    && 'Table'[Date] <= MAX ( 'Table'[Date] )
            )
        )
    )
RETURN
    AVERAGEX ( FILTER ( a, [Date] IN FILTERS ( [Date] ) ), [YTD] )

The result shows:

10.PNG

See my attached pbix file.

 

Best Regards,

Giotto

View solution in original post

7 REPLIES 7
Highlighted
Super User IV
Super User IV

Re: Bar Chart comparing monthly volume to Average monthly volume YTD

@wquayle yes you have to create a measure to calculate YTD avg. As a best practice, add date dimension in your model and use it for and time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools.

https://perytus.com/2020/05/22/create-a-basic-date-table-in-your-data-model-for-time-intelligence-ca...

 

YTD AVG = CALCULATE ( AVERGATE( Table[Column] ), DATESYTD ( DateTable[Date] ) ) 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

 






Did I answer your question? Mark my post as a solution.

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Highlighted
Community Support
Community Support

Re: Bar Chart comparing monthly volume to Average monthly volume YTD

Hi,

 

Please try these measures:

Current Month = 
IF (
    MONTH ( MAX ( 'Table'[Date] ) ) = MONTH ( TODAY () ),
    SUM ( 'Table'[Values] )
)
YTD = 
VAR a =
    SUMMARIZE (
        ALLSELECTED ( 'Table' ),
        'Table'[Date],
        'Table'[Category],
        "YTD", CALCULATE (
            SUM ( 'Table'[Values] ),
            FILTER (
                ALLSELECTED ( 'Table' ),
                'Table'[Category] IN FILTERS ( 'Table'[Category] )
                    && 'Table'[Date] <= MAX ( 'Table'[Date] )
            )
        )
    )
RETURN
    AVERAGEX ( FILTER ( a, [Date] IN FILTERS ( [Date] ) ), [YTD] )

The result shows:

10.PNG

See my attached pbix file.

 

Best Regards,

Giotto

View solution in original post

Highlighted
Frequent Visitor

Re: Bar Chart comparing monthly volume to Average monthly volume YTD

Appreciate your response and will absolutely provide Kudos. When I use the formula from your site the date, I get the following error message, "The column 'Year' in table 'Date' has invalid bindings specified." I deleted this line of code, and received another message, "The column Month' in table 'Date' has invalid bindings specified. Can you advise how to resolve this issue? Thank you, again!

Highlighted
Super User IV
Super User IV

Re: Bar Chart comparing monthly volume to Average monthly volume YTD

@wquayle is this related to my post? What you are referring too? 






Did I answer your question? Mark my post as a solution.

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Highlighted
Frequent Visitor

Re: Bar Chart comparing monthly volume to Average monthly volume YTD

 
Highlighted
Community Support
Community Support

Re: Bar Chart comparing monthly volume to Average monthly volume YTD

Hi,

 

If my previous reply has solved your issue, please mark it as a solution for others to see.

 

Best Regards,

Giotto

Highlighted
Frequent Visitor

Re: Bar Chart comparing monthly volume to Average monthly volume YTD

I appreciate your formulas and feedback. How would I re-write the formula to show data from the previous month instead of the current month?

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors