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

Show whole year while slicing on one month - DAX

Hello friends,

I have a Calendar Table with Year and Year-Month columns.

In my report - I have a Year-Month slicer, which allows a user to pick only one month (from the "Year-Month" column).

I need to create a chart that shows my Annual Budget by all month of the selected month's year.

For example, when a user selects "2017-June" - then my chart needs to show all of the 2017's months' budget - from January 2017 to December 2017.

I have to make my slicer only one month for other purposes. 

Currently the problem is that my chart shows only Jun-2017. Maybe I need to create a measure that will catch the selected month's year and calculate the budget for it only...

Please help

Thank you!

Michael

1 ACCEPTED SOLUTION

Hi @Anonymous,

You need to create a new table only including [Year-Month] column. Please click "New Table" under Modeling on Home page, type the formula below.Please note there is no relationshio between the New Table and your fact table.

 

NewTable=SELECTCOLUMNS(Table, “Year-Month”, Table[Year-Month])


Please use your table name replace the table in my formula. Create a measure using the formula below, add the measure in your chart.

Result = CALCULATE([Budget],FILTER(Sales,Sales[Year]=SELECTEDVALUE('Calendar'[Year])))


I test it using my sample table and get expected result. I have a 'sales' table with [Year], [Year-Month] and [SALE] value column. I create a Calendar table only including [Year-month]. I create a slicer including Calendar[Year-month], then create a measure using the formula.

Value = CALCULATE(SUM(Sales[SALE]),FILTER(Sales,Sales[Year]=SELECTEDVALUE('Calendar'[Year])))


Add sales[Year-Month] and [Value] measure in the line chart, which returns the right result as follows.

select 2014-01, it show all value of 2014select 2014-01, it show all value of 2014select 2013-09, it show all value of 2013select 2013-09, it show all value of 2013
Best Regards,
Angelia

View solution in original post

10 REPLIES 10
Greg_Deckler
Super User
Super User

Correct, you would want to create a measure that has an ALL or ALLEXCEPT filter clause in it or some other similar type of filter that ignores month.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Thanks, @Greg_Deckler but how?

I've tried Calculate([Budget],FILTER(ALL(CalendarTable),CalendarTable[Year]=MAX(CalendarYear[Year]))

But it still shows one month only - the selected one...

Please help

Thanks

Michael

Hi @Anonymous,

 

Try this

 

=Calculate([Budget],ALL(CalendarTable[Month]))

 

In the filter/slicer, select any one year.

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Thanks @Ashish_Mathur,

As I've stated - my slicer is a Year-Month (2017-12), not a Year.

I need this for other report purposes.

So a user always selects a certain Month.

For example, a user selects "2017-08", so I want my chart to show data only for 2017 - by All Months (January through December)

In your proposal you ask a user to select a year, this is not my case - I need the user to only choose a Month.

Please help,

Thank you!

Michael

Hi @Anonymous,

You need to create a new table only including [Year-Month] column. Please click "New Table" under Modeling on Home page, type the formula below.Please note there is no relationshio between the New Table and your fact table.

 

NewTable=SELECTCOLUMNS(Table, “Year-Month”, Table[Year-Month])


Please use your table name replace the table in my formula. Create a measure using the formula below, add the measure in your chart.

Result = CALCULATE([Budget],FILTER(Sales,Sales[Year]=SELECTEDVALUE('Calendar'[Year])))


I test it using my sample table and get expected result. I have a 'sales' table with [Year], [Year-Month] and [SALE] value column. I create a Calendar table only including [Year-month]. I create a slicer including Calendar[Year-month], then create a measure using the formula.

Value = CALCULATE(SUM(Sales[SALE]),FILTER(Sales,Sales[Year]=SELECTEDVALUE('Calendar'[Year])))


Add sales[Year-Month] and [Value] measure in the line chart, which returns the right result as follows.

select 2014-01, it show all value of 2014select 2014-01, it show all value of 2014select 2013-09, it show all value of 2013select 2013-09, it show all value of 2013
Best Regards,
Angelia

Hi,

 

Could you please share the PBIX you tested with? I did all the steps you described and reviewed them many times but I'm getting the value for the selected Month-Year showing for every month. 

 

Best regards,

 

Ferdinand

 

 

Hi everone,

 

I did it using ENDOFYEAR Function as below:

 

FY:=TOTALYTD([Values];ENDOFYEAR(Calendar[Date]))

considering my case, I don't have the date column, As I have only the month column and in this case, it will cant be used.

Please suggest if you have any.

Brilliant! no extra tables, beautiful simplicity!

Hi,

 

 

Have you tried my fomrula with a Year-Month selection.  If it does not work, then share the link from where i can download your file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.