Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Rakshhit_Sharma
Advocate I
Advocate I

Measure formula problem

I am writing some measures to calculate,let's say, sum of sales for past n months [n is 3,6,12,24,36]. All will be shown in cards.

I have data up until feb 2024 , starting from jan 2019

The normal measure for sum is

Sale_Sum = sum(tablename.columnname) 

This one is working fine.

When i tried to make specific measure , something like this:

Sale_Sum_3_months = Calculate(Sale_Sum, filter(tablename,datecolumn <= max(table.datecolumn) && datecolumn >= max(table.datecolumn)-90)). 

Again this is working fine. 

Slicers made of other columns working perfectly fine with this card. But problemcomes with year slicer. In all 5 cases[ 3,6,9,12,36 months ], when i select 2024, it shows data only for jan and feb 24, whereas technically it should sum of 3 months[ dec 23, jan 24, feb 24]. Also for 24, 36 month cases when 1 year is selected, lets say 2023, then only 2023 data is shown instead of showing 2023-22 data for 24 months and 2023-22-21 for 36 months. I tried using "all(tablename)" or "all(tablename.datecolumn" function in first part of filter where tablename is present , but then rest of slicers made from other columns will not work. Only year slicer will work. If i use removefilters(tablename) instead of tablename in filter column, then other slicers will work , but date colum or year slicer will not. Any suggesstions what else can I  try. I will try my best to give fast replies for solving this problem better.

It looks like date column and rest of column slicers working in different directions . One does not work with other. Any suggestion will be helpful

1 ACCEPTED SOLUTION

He tried to help you, reading theory is paramount in DAX/PBI. At minimum you need to have 2 separate tables (Sales and dates) here then only DAX will work otherwise DAX has a concept of "auto exists" it won't let your code return what you want unless you switch to star schema.

 

Even after that you would need a disconnected dates table because if you filter 2024 you can't just return dates of 2023, so you need a slicer that has year column from disconnected dates table that doesn't filter the visual directly, instead it is filtered based on the DAX code.

 

Here are 2 example of that disconnected dates table: https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-6th-month-max-date-sales/m-...

(select 2017 & 2018 from filters pane and then select any month from first quarter of 2018)

 

https://www.youtube.com/watch?v=A0h_0kf-0oI&ab_channel=AntrikshSharma

View solution in original post

8 REPLIES 8
MattAllington
Community Champion
Community Champion

Based on your description, it sounds like you have a single table. You should create a star schema. Here are some articles I wrote on the topic. 
https://exceleratorbi.com.au/the-optimal-shape-for-power-pivot-data/

https://exceleratorbi.com.au/dax-time-intelligence-beginners/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

That case is not possible. I am doing internship in a comapny. I have to manage this data in its current way. 

You do not need to ask for help on forums if you already know the correct answer.  🤷‍♂️



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

I have come here, because i do not know the solution. I am stuck at a junction where one type of filter will allow one set of slicers to work and other will allow different set. I am trying to find middle ground between those 2 filters . The community has always helped me in tough times. Thanks for cooperation

He tried to help you, reading theory is paramount in DAX/PBI. At minimum you need to have 2 separate tables (Sales and dates) here then only DAX will work otherwise DAX has a concept of "auto exists" it won't let your code return what you want unless you switch to star schema.

 

Even after that you would need a disconnected dates table because if you filter 2024 you can't just return dates of 2023, so you need a slicer that has year column from disconnected dates table that doesn't filter the visual directly, instead it is filtered based on the DAX code.

 

Here are 2 example of that disconnected dates table: https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Previous-6th-month-max-date-sales/m-...

(select 2017 & 2018 from filters pane and then select any month from first quarter of 2018)

 

https://www.youtube.com/watch?v=A0h_0kf-0oI&ab_channel=AntrikshSharma

Hi @AntrikshSharma @MattAllington , Come here to tell u guys that the problem is solved. Congratulations. The idea of making a new dimension date table from main date table worked well. Thanks for your ideas. Hope to again meet you guys with some new query. Thanks for your guidance, once again

Sorry for sounding rude. I will try your suggestions and come back with more updates. Thank you for your reply. @AntrikshSharma 

Then as an intern the first thing you learn and do today is to push back on bad data model and make them adapt the star schema.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.