Supplies are limited. Contact info@espc.tech right away to save your spot before the conference sells out.
Get your discountScore big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount
Hi,
I am facing a problem with handling slowly changing dimensions and calculating the delta.
The table looks like this:
Product | Owner | Start date | End date |
A | 123 | 1-Jan-24 | 1-Mar-24 |
B | 234 | 1-Feb-24 | 1-Apr-24 |
C | 345 | 1-Apr-24 | 1-May-24 |
D | 456 | 1-Feb-24 | 1-May-24 |
E | 123 | 1-Apr-24 | 1-May-24 |
The original dates that fill the date columns are monthly, that means: we get new data every month and decide on the start- and end- date every month.
What I would like to achieve is having a table that shows the delta per month, like this:
Products | Newly added | Removed | Delta | |
Jan-2024 | 1 | 1 | 0 | +1 |
Feb-2024 | 3 | 2 | 0 | +2 |
Mar-2024 | 2 | 0 | 1 | -1 |
Apr-2024 | 3 | 2 | 1 | 0 |
May-2024 | 0 | 0 | 3 | -3 |
How do I get to above result using DAX?
Solved! Go to Solution.
You can create measures like
Products =
VAR CurrentDate = MAX( 'Date'[Year month] )
VAR Result = CALCULATE(
COUNTROWS( 'Table' ),
'Table'[Start date] <= CurrentDate
&& 'Table'[End date] > CurrentDate
)
RETURN Result
Newly Added =
VAR CurrentDate = MAX( 'Date'[Year month] )
VAR Result = CALCULATE(
COUNTROWS( 'Table' ),
'Table'[Start date] = CurrentDate
)
RETURN Result
Removed =
VAR CurrentDate = MAX( 'Date'[Year month] )
VAR Result = CALCULATE(
COUNTROWS( 'Table' ),
'Table'[End date] = CurrentDate
)
RETURN Result
Delta = [Newly Added] - [Removed]
Hi @Janou ,
Thank you @johnt75 , for your excellent response! Your approach effectively captures newly added, removed, and delta values per month.
I’d like to expand on this with a small refinement to ensure products that end within the same month are correctly counted when calculating active products.
1.To ensure proper time intelligence calculations, first create a Date Table:
Now,plot a matrix visual then add MonthYear from DateTable to Rows field.
If our answer meets your requirement,consider accepting it as solution.
Thank you for being a part of Microsoft Fabric Community Forum!
Regards,
Pallavi.
Hi @Janou ,
As we have not received a response from you yet, I would like to confirm whether you have successfully resolved the issue or if you require further assistance.
If the issue has been resolved, please mark the helpful reply as a "solution" to indicate that the question has been answered and to assist others in the community.
Thank you for your cooperation. Have a great day.
Thanks a lot! The solutions worked!
Hi @Janou ,
As we have not received a response from you yet, I would like to confirm whether you have successfully resolved the issue or if you require further assistance.
If the issue has been resolved, please mark the helpful reply as a "solution" to indicate that the question has been answered and to assist others in the community.
Thank you for your cooperation. Have a great day.
Hi @Janou ,
Thank you @johnt75 , for your excellent response! Your approach effectively captures newly added, removed, and delta values per month.
I’d like to expand on this with a small refinement to ensure products that end within the same month are correctly counted when calculating active products.
1.To ensure proper time intelligence calculations, first create a Date Table:
Now,plot a matrix visual then add MonthYear from DateTable to Rows field.
If our answer meets your requirement,consider accepting it as solution.
Thank you for being a part of Microsoft Fabric Community Forum!
Regards,
Pallavi.
You can create measures like
Products =
VAR CurrentDate = MAX( 'Date'[Year month] )
VAR Result = CALCULATE(
COUNTROWS( 'Table' ),
'Table'[Start date] <= CurrentDate
&& 'Table'[End date] > CurrentDate
)
RETURN Result
Newly Added =
VAR CurrentDate = MAX( 'Date'[Year month] )
VAR Result = CALCULATE(
COUNTROWS( 'Table' ),
'Table'[Start date] = CurrentDate
)
RETURN Result
Removed =
VAR CurrentDate = MAX( 'Date'[Year month] )
VAR Result = CALCULATE(
COUNTROWS( 'Table' ),
'Table'[End date] = CurrentDate
)
RETURN Result
Delta = [Newly Added] - [Removed]
User | Count |
---|---|
12 | |
12 | |
8 | |
8 | |
6 |
User | Count |
---|---|
27 | |
19 | |
13 | |
11 | |
7 |