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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
cARLOSPERALTA
Advocate I
Advocate I

Filter Rows of Dim Column for Previous Year's Data to Only Include Row's Existing in Current Year

Hello PBI Community,

 

I have to calculate the growth of sales based on Countries. I have about 50 countries in my dimension table, and a fact table that has data per week. Since not all countries data's are available at the same time for the the current year data, and that my client doesn't want to wait until we have all the countries available to show the data, I have a miscalculation in my growth number because I'm calculating the available countries for this year vs. All the countries available last year.

 

I need to find a solution that would filter the previous year's data based on the countries available for the current period.

 

Any help would be appreciated!

 

Thanks,

 

Carlos P.

www.carlosperalta.dev

3 REPLIES 3
Anonymous
Not applicable

Hi @cARLOSPERALTA 

Can you provide the data description or pbix file ? This may help us deal with your problem more easily.

 

Best Regards,
Community Support Team _ Ailsa Tao

cARLOSPERALTA
Advocate I
Advocate I

Hi @amitchandak ,

 

I have no issue to get my previous year's data.

 

My issue is that I have to get my previous year's data only for my countries available in 2022.

 

For example, in 2022, Canada, USA and Belgium is available but in 2021 Canada, USA, Belgium, France, Germany and Japan are available. So to calculate growth, I only have to consider Canada, USA and Belgium, which are the markets available in the current period.

 

 

amitchandak
Super User
Super User

@cARLOSPERALTA , if you have year and week.

You need create a year week table with Key [Year]*100 +[week] to join with data and week/date table 

 


//Only year vs Year, not a level below

This Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('Table'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))

 

This week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year]) && 'Date'[Week] = Max('Date'[Week]) ))
Last year same week = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])-1 && 'Date'[Week] <= Max('Date'[Week])))

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.