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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
fabienrolland
Frequent Visitor

Compare 2 equivalent periods without date

Hi,

 

I have a Marketing Cycle Calendar that shows for each date, the corresponding cycle year, cycle name, cycle number, etc. See below

DATECYCLE_NBCYCLE_NAMECYCLE_DAYCYCLE_WEEKCYCLE_YEAR
25/12/201701Soldes Hiver112018
26/12/201701Soldes Hiver212018
27/12/201701Soldes Hiver312018
28/12/201701Soldes Hiver412018
29/12/201701Soldes Hiver512018
30/12/201701Soldes Hiver612018
31/12/201701Soldes Hiver712018
01/01/201801Soldes Hiver822018
02/01/201801Soldes Hiver922018
03/01/201801Soldes Hiver1022018
04/01/201801Soldes Hiver1122018
05/01/201801Soldes Hiver1222018
06/01/201801Soldes Hiver1322018
07/01/201801Soldes Hiver1422018
08/01/201801Soldes Hiver1532018
09/01/201801Soldes Hiver1632018
10/01/201801Soldes Hiver1732018
11/01/201801Soldes Hiver1832018
12/01/201801Soldes Hiver1932018
13/01/201801Soldes Hiver2032018
14/01/201801Soldes Hiver2132018
15/01/201801Soldes Hiver2242018
16/01/201801Soldes Hiver2342018
17/01/201801Soldes Hiver2442018
18/01/201801Soldes Hiver2542018
19/01/201801Soldes Hiver2642018
20/01/201801Soldes Hiver2742018

 

The CYCLE_CALENDAR is linked to the main Calendar table which is linked to the fact tables. 

One of the fact tables (SALE_HEADER) includes Sales amount.

 

I am trying to calculate the Sales amount corresponding to the same period last year.

 

CA YR PY (Cycle equivalent dates) =
CALCULATE(
SUM(SALE_HEADER[SALES AMOUNT]);
FILTER(ALL(CYCLE_CALENDAR);
CYCLE_CALENDAR[CYCLE_YEAR] = MIN(CYCLE_CALENDAR[CYCLE_YEAR]) - 1 &&
CYCLE_CALENDAR[CYCLE_NB] = MIN(CYCLE_CALENDAR[CYCLE_NB]) &&
CYCLE_CALENDAR[CYCLE_DAY] = MIN(CYCLE_CALENDAR[CYCLE_DAY])
)
)

 

It works at the CYCLE_DAY level, but when i Agregate by  month or year i get the value corresponding to the smallest date (Probably because i used the MIN() in my DAX function).

How can i solve this? Thanks a million

Sorry i couldnt copy paste a print screen

 

AnnéeTrimestreMoisJourCA YRCA YR PY (Cycle equivalent dates)
2018Trim 1février14$87790$48938
2018Trim 1février18$74676$67662
2018Trim 1février15$88417$73797
2018Trim 1février17$101244$95656
2018Trim 1février16$101958$104137
Total février   $454085$48938
Total 2018   $454086$48939
1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@fabienrolland,

 

You may take a look at https://www.sqlbi.com/articles/compare-equivalent-periods-in-dax/.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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