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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Gab78
New Member

Filter by date column data

Hi guys,

 

sales.png


I have two tables, one date table with date columns, year, year+month, long date, week of the year, day of the week (e.g. Sunday=0, Monday =1, etc), and a last calculated column which is made up by concatenating the "year + week of the year+ day of the week".
The other table is sales, there I have the store code, the amount of the sale and the date.

I am trying that from a date selection, calculate the sales of the previous year but in relation to the same week and same day, show them in the same table.

 

I have created the following dax.

 

M.fct_salesLY =
VAR lastyear =
CALCULATE (
SUM (FCT_sales[sales]),
FILTER (ALL (date), date[YWDN] -1000 )
)
RETURN
IF(lastyear= BLANK(),0,lastyear)

Can you think of any other alternative.
Regards

 

2 REPLIES 2
SamInogic
Super User
Super User

Hi,

 

You can try it by creating a same column in sales Table by concatenating the "year + week of the year+ day of the week" 

After this, create a relationship between the Tables using column [YWON]

We have created below two tables:

Table 1:

SamInogic_1-1673495356003.png

Table 2:

SamInogic_2-1673495391847.png

 

Now, create a column using below DAX Expression

 

YWON = CONCATENATE([SD].[Year],CONCATENATE(WEEKNUM([SD].[Date],1),WEEKDAY([SD]))-1)

SamInogic_3-1673495426828.png

Next step will be to create a Relationship between both Tables,

SamInogic_4-1673495454309.png

Add a Slicer Visual and add Year column of Table 1, as shown in the below screenshot.

SamInogic_5-1673495475146.png

As we have created a Relationship between two tables using [YWON] column, we can filter the data by [YWON]
Green : [YWON] sales Table

Red : [YWON] First Table

SamInogic_6-1673495499989.png

When last year is selected in the Slicer then, it is also filtering the Sales Table by the [YWON] (Because of the Relationship).

For the Calculation, you can use the Column Aggregation functions available in Power BI as shown in the below screenshot.

SamInogic_8-1673495706618.png

If this answer helps, please mark it as Accepted Solution so it would help others to find the solution.

Thanks!

Inogic Professional Services

An expert technical extension for your techno-functional business needs

Power Platform/Dynamics 365 CRM

Drop an email at crm@inogic.com

Service:  http://www.inogic.com/services/ 

Power Platform/Dynamics 365 CRM Tips and Tricks:  http://www.inogic.com/blog/

Inogic Professional Services: Power Platform/Dynamics 365 CRM
An expert technical extension for your techno-functional business needs
Service: https://www.inogic.com/services/
Tips and Tricks: https://www.inogic.com/blog/
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely.
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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.