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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Exclude Customers who had sales in one year but not in the other

Hello, I would like to create slicer, some kind of filter or measure which will exclude in the calculation Customers who had sales in one month of one year but not in the same month previuos year. For example this Customer did not have sales in 2022 11 and 12 then 2022 11,12 and 2021 11,12 should be excluded from the total.

 

 

Ania26_0-1678391582716.png

 

 

6 REPLIES 6
Anonymous
Not applicable

Hello,
In the attached sample data I have two Customers A & B. I want to compare their sales in 2021 and 2022. If Customer did not have sales in any of the months then this month should also be excluded from the other year so I want to compare apple to apple. For example: Customer A: did not have sales in 11 & 12 of 2022 so his total sales in 2021 should be 800euro and in 2022 also 800euro because we are excluding 11 & 12 month. The same rule applies for Customer B, he also should have 800euro sales in each year.

https://teamshimano-my.sharepoint.com/:u:/r/personal/anna_zalewa-goddijn_shimano-eu_com/Documents/De... 

YearMonthAMTCustomer Name      
20211€ 100A      
20212€ 100A      
20213€ 100A      
20214€ 100A      
20215€ 100A      
20216€ 100A      
20217€ 100A      
20218€ 100A      
20219€ 100A      
202110€ 100A      
202111€ 100A      
202112€ 100A      
20221€ 100A      
20222€ 100A      
20223€ 100A      
20224€ 100A      
20225€ 100A      
20226€ 100A      
20227€ 100A      
20228€ 100A      
20229€ 100A      
202210€ 100A      
20211€ 100B      
20212€ 100B      
20213€ 100B      
20214€ 100B      
20215€ 100B      
20216€ 100B      
20217€ 100B      
202110€ 100B      
202111€ 100B      
202112€ 100B      
20221€ 100B      
20222€ 100B      
20223€ 100B      
20224€ 100B      
20225€ 100B      
20226€ 100B      
20227€ 100B      
20228€ 100B      
20229€ 100B      
202210€ 100B      
202211€ 100B      
202212€ 100B      

So something like this?

lbendlin_1-1678715531380.png

 

 

When you say you want to "compare sales" - how should that look like?  Show the adjusted sales per customer and year, or show some YoY percentage? Will there always be two years involved? What if there are three or more years?

 

Anonymous
Not applicable

SO what I want to have: I have slicers Year (2016-2023) and Month and if I select minimum two years and one month I want to exclude Customers who did not have sales in one of those months or of course both months. I want to have TTL and compare apple to apple. So what you calculated is correct, let me check in my report if it works as I want. Thank you for now!

Anonymous
Not applicable

Hello, I have applied your formula to my table and have no result: 

AAA = var A=CALCULATETABLE(SUMMARIZE('A_Report Dataset_DSTM_SalesHistory','A_Report Dataset_DSTM_SalesHistory'[Month],"ct",COUNTROWS('A_Report Dataset_DSTM_SalesHistory')),REMOVEFILTERS('A_Report Dataset_DSTM_SalesHistory'[Year])) var B=SELECTCOLUMNS(FILTER(A,[ct]=2),"Month",'A_Report Dataset_DSTM_SalesHistory'[Month]) return CALCULATE(SUM('A_Report Dataset_DSTM_SalesHistory'[Sales Amount Euro]),B)
 
Could you please step by step explain what this formuls does?
Could it be that it does not work because my table has data for 5 years so the amount of months could be never 2? 

Yes, I asked you about this earlier. CT is the count of rows. In order to make the formula work with any number of years you need to do a distinct count of years rather than hard coding it to two.

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors