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
Anonymous
Not applicable

Complex Dates compare

Hello Experts,

Please help me with this date comparison.

I have a dates table with Snapshots Column where we take Snapshots every other Saturday. Sometimes there may be only one snapshot per month.

Ex Dates data comes in one column. 

If the user selects CY date 12/03/2022, they want to see the same metric for LY and LLY.

 

CYLYLLY
12/31/202212/04/202112/05/2020
12/03/202212/04/202112/05/2020
11/12/202211/13/202111/14/2020
10/29/202210/30/202110/31/2020
10/15/202210/30/202110/31/2020
10/01/202210/02/202110/03/2020
09/17/202209/18/2021 
09/03/202209/18/2021 
08/20/202208/28/2021 
07/30/202207/31/2021 
07/16/202207/31/2021 
07/02/202207/03/2021 
06/18/202206/19/2021 
05/28/202205/29/2021 
05/14/202205/01/2021 
04/30/202204/17/2021 
04/16/202204/17/2021 
04/02/202204/03/2021 
03/19/202203/20/2021 
02/26/202202/27/2021 

 

Expercted Output:

 

CY12/03/2022100
LY12/04/2021299
LLY12/05/2020150

 

Thanks.

11 REPLIES 11
andhiii079845
Solution Sage
Solution Sage

My solution:
1) First you need a second table "Dimtable" with distinct date values from the other table (Via Power Query Editor: reference table and remove duplicate )

Bildschirmfoto 2023-02-25 um 14.52.38.png

2) Create a slicer with the Dimtable Date column and matrix with date, sales column from the table "example" 

 
Bildschirmfoto 2023-02-25 um 14.55.02.png

3) DAX Formular:

FilterData = 

VAR _selectmonth2 = MONTH(SELECTEDVALUE(Dimtable[Date]))
VAR _currentmonth = MONTH(maxx(example,example[Date]))
VAR  _filter = IF(_currentmonth=_selectmonth2,1,0)

RETURN _filter
 
4) Filter the matrix visual with the FilterData Measure (greater than or equal to 1)
andhiii079845_0-1677333386327.png

 

I hope this was a good walkthrough. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Could you please share the dataset with me?

 

Thank you

The link:
https://wetransfer.com/downloads/73897095db391911505c5acaa37feefd20230225151617/6d1cfe9fe7a0cb091788...





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Hi @andhiii079845 ,

Your solution is good for Month Selection. I want it by date.

EX:If the user Selects 

CY12/03/2022

The output should be like below.

CY12/03/2022100
LY12/04/2021299
LLY12/05/2020150

 

Thanks a lot for your time. 

What do you mean per date? The slicer is via date ans than looking for the same month in a other year. I not really understand the logic. 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

 sorry 

If the user selects data 12/03/2022,  then the result should be these dates 

CY12/03/2022100
LY12/04/2021299
LLY12/05/2020150

The goal is to compare CY date with previous year dates sales amount.

Okay, what is exactly wrong in my solution? Do you want to calculate a sum per month or something like this? 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




andhiii079845
Solution Sage
Solution Sage

The logic is that all snapshot from the LY und LLY in the same (selected) month should be shown? 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

@andhiii079845 

 

Yes, That's correct.

 

All these are examples.

If they select CY date the patten is like below.

 

CYLYLLY
12/31/202212/04/202112/05/2020
12/03/202212/04/202112/05/2020
11/12/202211/13/202111/14/2020
10/29/202210/30/202110/31/2020
10/15/202210/30/202110/31/2020
10/01/202210/02/202110/03/2020
09/17/202209/18/2021 
09/03/202209/18/2021 
08/20/202208/28/2021 
07/30/202207/31/2021 
07/16/202207/31/2021 
07/02/202207/03/2021 
06/18/202206/19/2021 
05/28/202205/29/2021 
05/14/202205/01/2021 
04/30/202204/17/2021 
04/16/202204/17/2021 
04/02/202204/03/2021 
03/19/202203/20/2021 
02/26/202202/27/2021 

Thank you.

andhiii079845
Solution Sage
Solution Sage

I have some question to it: 
1) Date is MM/DD/YYYY in your example? 
2) Are CY,LY,LLY separate columns? Where are the metrics? Do you have a example for it?
3) If you select one month and there are more snapshot in this month, which one should be selected: all? the last one? 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Hi @andhiii079845 ,

Thank you for looking into it.

 

I have some question to it: 
1) Date is MM/DD/YYYY in your example?  Yes, Its a date column.
2) Are CY,LY,LLY separate columns? They all come from one date column. I seperated them by year to explain better.
Where are the metrics? I added test data (Please see below)
Date table Key joind to Fact tables

 

DateSales
12/31/2022125
12/03/2022126
11/12/2022127
10/29/2022128
10/15/2022129
10/01/2022130
09/17/2022131
09/03/2022132
08/20/2022133
07/30/2022134
07/16/2022135
07/02/2022136
06/18/2022137
05/28/2022138
05/14/2022139
04/30/2022140
04/16/2022141
04/02/2022142
03/19/2022143
02/26/2022144
12/04/2021145
12/04/2021146
11/13/2021147
10/30/2021148
10/30/2021149
10/02/2021150
09/18/2021151
09/18/2021152
08/28/2021153
07/31/2021154
07/31/2021155
07/03/2021156
06/19/2021157
05/29/2021158
05/01/2021159
04/17/2021160
04/17/2021161
04/03/2021162
03/20/2021163
02/27/2021164
12/05/2020165
12/05/2020166
11/14/2020167
10/31/2020168
10/31/2020169
10/03/2020170


Do you have a example for it? Yes added 

3) If you select one month and there are more snapshot in this month, which one should be selected: all? the last one?  

CY12/03/2022126
LY12/04/2021145
LLY12/05/2020165

This is good example.

They took two snapshots in 2022 , but previous year only one. 

If users selects 12/31/2022, or 12/03/2022 , the pattern shold be like below.

 

12/31/202212/04/202112/05/2020
12/03/202212/04/202112/05/2020

 

Thanks a lot.

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.