Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
Check it out now!Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
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?
Solved! Go to Solution.
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:
See my attached pbix file.
Best Regards,
Giotto
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:
See my attached pbix file.
Best Regards,
Giotto
@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!
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
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.
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!
@wquayle is this related to my post? What you are referring too?
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
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.
Hi,
If my previous reply has solved your issue, please mark it as a solution for others to see.
Best Regards,
Giotto
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?