Level: Intermediate.
I had a great question pass my way last week while I was at the Microsoft Business Application Summit. The problem presented by Matt (a different Matt, not me) was that he had around 200 measures already written, but wanted to be able to toggle the report pages between YTD and Full Year data. For the sake of this article I will be using Year to Date (YTD) and Moving Annual Total (MAT) as the 2 toggle events.
Why Not Use a Switch Measure?
OK, why not use a switch measure to solve this problem I hear you say? Well the issue is there are already 200 measures that are working just fine. Using the switch measure approach would mean having to write new measures for EVERYTHING that needed to react to the switch measure slicer. Instead Matt (the other Matt) had an idea to filter the calendar table based on the slicer selection, and have that impact ALL of the existing measures – great idea Matt!
But there is a problem with this approach. Normally a slicer (in this case a slicer to toggle the filter on the calendar table) would have a single column with a Mutually Exclusive, Collectively Exhaustive (MECE) list of selection options. As you can see in the image below, the Months highlighted in green need to be used in BOTH YTD and MAT. So there is no way to use a single column in the Calendar table to solve this one.
How About 2 Columns in the Calendar Then?
Yes that would work. You could create 2 new columns in the calendar table, one for a YTD flag and another for a MAT flag – that would work. But of course the user would need to know they needed to select “Yes” to one and “No” to the other slicer – not a good experience. So what to do?
Think About The Problem!
If you think about the problem above, each date (month in this case) can participate in both scenarios (YTD and MAT). That sounds like a 1 to many relationship problem. So once you understand that, it should become obvious that you will need a data table that contains the month records that belong to each use case. The months that are in both scenarios will be duplicated in the new data table. The best way to explain it is by showing the final data model.
I have created a bridge table called AllMonths. This contains a distinct list of all the months in the calendar table in the format YYMM.
I also created a TimePeriod table that contains the list of months that map to YTD and also map to MAT. The data in the TimePeriod table is shown below, and it is joined to the AllMonths table with a bi-directional filter as shown above. Each month can participate in both period mappings and hence this is technically a data table. The bi-directional filter means that any slicer on this table will push the filter onto the AllMonths table. The AllMonths table will automatically filter the Calendar table.
As you can see with the data in the TimePeriod table above (sample data), the Moving Annual Total covers the periods July 2003 through June 2004, and the YTD period is Jan 2004 through June 2004. In other words, all the periods YTD are also included in the MAT. I am simulating the sample data showing the current period as being the end of June 2004. In real life, you would use some sort of calculated table to automatically update on refresh to keep this table up to date for the current period.
The Final Result
The net result is as follows. The Period slicer below comes from the TimePeriod table. As long as you select one of the periods in this slicer, ALL of the measures in the entire data model will update to reflect that period of time without having to write custom measures that react to the slicer.

How to Make the Period Table Automatic
There was a good question in the comments from Uriel about just “how” the period table would auto update. I didn’t provide a solution originally as Matt said it was working for him. I had a play around with some DAX and came up with the following table DAX formula.
TestTable =
VAR datetoday = date(2004,7,5) //replace this with TODAY() in real life
VAR CompletedMonthID = CALCULATE(SELECTEDVALUE('Calendar'[MonthID]),'Calendar'[Date]=datetoday) -1
VAR MATfrom = CompletedMonthID - 11
VAR YTDStartDate = CALCULATE(STARTOFYEAR('Calendar'[Date]),'Calendar'[Date]=datetoday)
VAR YTDMonthID = CALCULATE(SELECTEDVALUE('Calendar'[MonthID]),'Calendar'[Date]=YTDStartDate)
VAR MATTable = ADDCOLUMNS(GENERATESERIES(MATfrom,CompletedMonthID),"Period","MAT")
VAR YTDTable = ADDCOLUMNS(GENERATESERIES(YTDMonthID,CompletedMonthID),"Period","YTD")
RETURN UNION(MATTable,YTDTable)
This code will generate a period table that should stay up to date each time the data is refreshed. I have used a MonthID column in the calendar table instead of the YYMM column, so that would mean the bridge table would need to be switched to use that too. Here is my workbook. Adventure Works Filter Calendar table
The approach above is relatively complex. It would probably be slightly easier to add 2 new calculated columns for MAT and YTD. These would be relatively easy to write using IF statements to determine which dates qualify for each. Once these are in the calendar table, it would again be relatively easy to create a complete list of all dates as I have done above. Something like this I guess.
TestTable2 =
VAR MATTable = FILTER(ALL(Calendar[YYMM],Calendar[MAT]),Calendar[MAT]="MAT"))
VAR YTDTable = FILTER(ALL(Calendar[YYMM],Calendar[YTD]),Calendar[YTD]="YTD"))
RETURN UNION(MATTable,YTDTable)


Great advice Many thanks.
my webpage; https://contests.covers.com
Senior Friend Finder is marketed as a free courting site, and everybody who signs up has chatting and on the spot messaging privileges. You should also request a free copy of your credit score report back to check for suspicious activity.
People must usually undergo a consultation and receive a prescription before ordering from these companies. How you choose to accomplish these things will determine the results you get with your enlargement show.
Plus, you can even reap the benefits of free shipping on orders over certain amounts.
I’m not going to do because they recommendation PENIS ENLARGEMENT PILL was just the porsche people who suffered from small winkies. If you are going to try these pills anyway, tread carefully and conduct thorough research.
Nevertheless, some sufferers could decide to keep away from pharmaceutical products totally. When used correctly, it will increase blood circulation to the penis, producing short-time period alleviation from the situation.
Our Chattanooga office is in the heart of the city, and we welcome patients from the wider Chattanooga region and its neighboring cities. She had learned from her master about stewing fish. Most patients have a doubling of the flaccid penis size.
Helpful postings, Cheers!
my webpage https://cse.google.pt/url?sa=i&url=https://kolab.network/blog/
I genuinely enjoy looking through on this web site, it holds wonderful blog posts.
It’s an remarkable post in support of all the internet visitors;
they will get advantage from it I am sure.
You actually reported it effectively!
Feel free to surf to my blog: https://lerwill-life.org.uk/
Kudos! I value it.
Look at my site https://trackingkolab.com/
Nicely put. Thank you.
Feel free to surf to my webpage https://cyberhead.ru/redirect/?url=http%3a%2f%2fkolab.network%2Ffeatures%2F
谢谢, 大量 知识!
Feel free to visit my site … https://bridgetsboutique.co.uk/
非常感谢, 奇妙 信息。
My homepage :: https://chinese-embassy.org.uk/
Thanks a lot, I appreciate it.
Kudos. I appreciate it!
My web-site :: https://www.depher.co.uk/
Kudos, Useful stuff.
Here is my webpage :: buy finasteride online how to buy online [https://thesaracensatbrington.co.uk/]
You are my breathing in, I have few web logs and occasionally run out from post :). “Analyzing humor is like dissecting a frog. Few people are interested and the frog dies of it.” by E. B. White.
Proof blog you procure here.. It’s severely to espy high quality writing like yours these days. I really respect individuals like you! Rent guardianship!! https://lzdsxxb.com/home.php?mod=space&uid=5113093
orlistat pills – click cheap orlistat 60mg
Would you be interested in exchanging links?
We’re a bunch of volunteers and starting a brand new scheme in our community. Your website offered us with useful info to paintings on. You’ve done a formidable activity and our whole community will likely be thankful to you.
order dapagliflozin 10mg sale – https://janozin.com/# order forxiga generic
Keep functioning ,splendid job!
I’ll certainly return to skim more. http://www.predictive-datascience.com/forum/member.php?action=profile&uid=44942
You should take part in a contest for one of the best blogs on the web. I will recommend this site!
This website positively has all of the bumf and facts I needed about this thesis and didn’t positive who to ask.
https://proisotrepl.com/product/clopidogrel/
This website absolutely has all of the information and facts I needed adjacent to this participant and didn’t know who to ask. https://ondactone.com/spironolactone/
Interesting blog! Is your theme custom made or did you download it from somewhere? A design like yours with a few simple adjustements would really make my blog stand out. Please let me know where you got your theme. Many thanks
Perfectly composed written content, regards for information. “You can do very little with faith, but you can do nothing without it.” by Samuel Butler.
Definitely believe that which you stated. Your favorite justification appeared to be on the web the easiest thing to be aware of. I say to you, I definitely get annoyed while people think about worries that they plainly do not know about. You managed to hit the nail upon the top and also defined out the whole thing without having side effect , people could take a signal. Will likely be back to get more. Thanks
I like this weblog so much, saved to fav.
Thanks on sharing. It’s acme quality. https://aranitidine.com/fr/viagra-professional-100-mg/
With thanks. Loads of knowledge! ursxdol
Greetings! Very serviceable advice within this article! It’s the scarcely changes which will espy the largest changes. Thanks a quantity for sharing! https://gnolvade.com/
This website really has all of the bumf and facts I needed about this subject and didn’t identify who to ask. https://buyfastonl.com/isotretinoin.html
viagra online discount – viagra sale ireland buy viagra professional online no prescription
buy ranitidine online cheap – site zantac online
cialis overnight deleivery – ciltad genesis what is the difference between cialis and tadalafil
cenforce 50mg without prescription – https://cenforcers.com/ cenforce 100mg usa
buy fluconazole 100mg generic – site diflucan 200mg brand
cheap amoxicillin online – https://combamoxi.com/ buy amoxicillin paypal
I don’t even know how I ended up here, but I thought this post was great. I don’t know who you are but definitely you are going to a famous blogger if you are not already 😉 Cheers!
I’d constantly want to be update on new articles on this website , saved to my bookmarks! .
I got what you mean ,saved to fav, very decent internet site.
I’ve been surfing on-line more than 3 hours today, yet I never found any fascinating article like yours. It¦s lovely value sufficient for me. Personally, if all web owners and bloggers made excellent content material as you did, the net will likely be much more helpful than ever before.
Hey would you mind stating which blog platform you’re using? I’m looking to start my own blog in the near future but I’m having a tough time choosing between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I’m looking for something completely unique. P.S Sorry for getting off-topic but I had to ask!
Excellent post. I was checking constantly this blog and I’m inspired! Extremely helpful information specially the final part 🙂 I handle such info much. I used to be looking for this particular info for a very lengthy time. Thank you and best of luck.
Thankyou for this wonderful post, I am glad I detected this internet site on yahoo.
I’ve recently started a web site, the information you offer on this web site has helped me greatly. Thank you for all of your time & work. “The man who fights for his fellow-man is a better man than the one who fights for himself.” by Clarence Darrow.
The title of this blog-post doesn’t do the brilliance of the technique justice, Matt. This is a very clever design pattern. The obvious extension – that would be trivial to implement with the samples already provided – is a toggle between Calendar and Fiscal Year, in addition to the MAT.
A toggle between Calendar Year and Fiscal Year is a great idea – for those that need such a solution. You are right, it is essentially the same problem.
Yet another exceptional article Matt. You explain things phenomenally.
Matt you do a great job with your articles. Thank you very much.
In your solution of the TestTable you make use of a Calendar table. Would you please also give the code related to your Calendar table that is referenced? Perhaps it was in earlier published articles. I have created my own calendar table and want to make sure when I reference my columns I am picking the corresponding equivalent column in your solution.
I have added my workbook to the post at the bottom.
Innovative solution thank you for sharing. But 200 calculated measures?! How could all of them be necessary? I’d be looking for a way to clean up my source data by that point.
That’s nice in PowerBI but Excel still doesn’t have bi-directional filters. Now of course you could go and use CROSSFILTER but I believe you’d still have to rewrite all your measures then, which defeats the purpose. Is there another way? Currently I’m managing this by manipulating a timeline slicer with VBA, but macros are increasingly “not done” in cybersecurity conscious organizations.
I don’t know of a way to do this in Excel at this stage without editing the measures.
How much compromising are you willing to accept Godan?
Say a slicer with items ( MAT | YTD | (Blank) ) where (Blank) on select shows aggregations for all months, dates prior to the first date of MAT.
Not sure what you mean or how to implement it. Of course I’d prefer to have my slicers look as professional as possible with no weird stuff like (blank), but if a hack is the only way to do it then a hack it is!
Yeah, I didn’t provide a solution for that as the other Matt said he got it working. It would of course depend on your year and how the data is loaded. I have added a sample back in the blog
I am not sure I understand how the Period column in the TimePeriod table is going to change next month to show the right periods?
Am I supposed to update them manually every month?