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.
Hi everyone,
So my table looks like this
AccountNumber | F | C | Type | Period |
A23234 | $532 | $85 | I | 12/31/2019 |
A56544 | $3,323 | $73 | C | 12/31/2019 |
A84736 | $812 | $22 | C | 12/31/2019 |
A99384 | $729 | $99 | C | 12/31/2019 |
A38394 | $3,524 | $2,363 | I | 12/31/2019 |
A23234 | $539 | $95 | I | 2/29/2020 |
A56544 | $3,333 | $72 | C | 2/29/2020 |
A84736 | $812 | $85 | I | 2/29/2020 |
A38394 | $3,434 | $2,323 | I | 2/29/2020 |
We get new account data every month end or so, we always want our comparisons compared to the last quarter end data. So in this instance 2/29 is our most recent period and we're comparing to 12/31. If the period is 5/31 then we'd compare it to 3/31, etc etc
This is the main formula I want to apply for each account, then add it all up for one final #
(Current Period [F] - Prior Period [F]) * (Prior Period [C] / Prior Period [F] )
Issues I'm having
Any help would really be appreciated here, pulling my hair out trying to figure it out, thanks!
HI @Anonymous
For your case, you could try this way as below:
Step1:
Add two dim tables and create two relationships as below:
Dim AccountNumber = VALUES('Table'[AccountNumber])
Dim Period = VALUES('Table'[Period])
Step2:
Create a measure as below:
Measure =
VAR _CurrentPeriodF= CALCULATE(SUM('Table'[F]))
var _PriorPeriodF= CALCULATE(SUM('Table'[F]),FILTER(ALL('Dim Period'),DATEDIFF('Dim Period'[Period],MAX('Dim Period'[Period]),MONTH)=2))
VAR _PriorPeriodC= CALCULATE(SUM('Table'[C]),FILTER(ALL('Dim Period'),DATEDIFF('Dim Period'[Period],MAX('Dim Period'[Period]),MONTH)=2))
RETURN
(_CurrentPeriodF-_PriorPeriodF)*(_PriorPeriodC/_PriorPeriodF)
If an account is type I and stays type I, I don't care about it. Only C's that stay C's and C's that become I's.
Do you mean you want to add a conditional that type is "C"?
for example:
Measure 2 =
VAR _CurrentPeriodF= CALCULATE(SUM('Table'[F]),FILTER('Table','Table'[Type]="C"))
var _PriorPeriodF= CALCULATE(SUM('Table'[F]),FILTER('Table','Table'[Type]="C"),FILTER(ALL('Dim Period'),DATEDIFF('Dim Period'[Period],MAX('Dim Period'[Period]),MONTH)=2))
VAR _PriorPeriodC= CALCULATE(SUM('Table'[C]),FILTER('Table','Table'[Type]="C"),FILTER(ALL('Dim Period'),DATEDIFF('Dim Period'[Period],MAX('Dim Period'[Period]),MONTH)=2))
RETURN
(_CurrentPeriodF-_PriorPeriodF)*(_PriorPeriodC/_PriorPeriodF)
Here is sample pbix file, please try it.
If not your case, please share your expected output based on the sample data.
Regards,
Lin
Thank you so so so much! Your sample file is very very close to what I need.
Here is what the calculations should be for each account
AccountNumber | F | C | Type | Period | Calculation | Notes |
A23234 | $532 | $85 | I | 12/31/2019 | ||
A23234 | $539 | $95 | I | 2/29/2020 | 0 | Account was type I in previous quarter so formula doesn't apply |
A38394 | $3,524 | $2,363 | I | 12/31/2019 | ||
A38394 | $3,434 | $2,323 | I | 2/29/2020 | 0 | Account was type I in previous quarter so formula doesn't apply |
A56544 | $3,323 | $73 | C | 12/31/2019 | ||
A56544 | $3,333 | $72 | C | 2/29/2020 | 0.219681011 | (_CurrentPeriodF-_PriorPeriodF)*(_PriorPeriodC/_PriorPeriodF) |
A84736 | $812 | $22 | C | 12/31/2019 | ||
A84736 | $812 | $85 | I | 2/29/2020 | 0.000000 | (_CurrentPeriodF-_PriorPeriodF)*(_PriorPeriodC/_PriorPeriodF) |
A99384 | $729 | $99 | C | 12/31/2019 | -99 | (0 -_PriorPeriodF)*(_PriorPeriodC/_PriorPeriodF) |
-98.780319 | Final Number I want |
Differences to what is in the sample pbix
Period I'm filtering on | Period to Compare Against |
1/31/2020 | 12/31/2019 |
2/29/2020 | 12/31/2019 |
3/31/2020 | 12/31/2019 |
4/30/2020 | 3/31/2020 |
5/31/2020 | 3/31/2020 |
6/30/2020 | 3/31/2020 |
Thanks again, I can't even put into words how much this has helped already @v-lili6-msft
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
96 | |
76 | |
63 | |
55 |
User | Count |
---|---|
142 | |
107 | |
89 | |
84 | |
65 |