Forum Discussion
Need help with Power Bi calc
- 1 year ago
Thanks bhanu, i couldnt play with it much, when i used teh logic, i still couldnt get the calc correctly, i will work on it this week and will keep you posted.
- 1 year ago
Hi,
Based on the table that you have shared, show the expected result very clearly.
- 1 year ago
Hi,
PBI file attached.
Hope this helps.
Swathykorivi Try using
DAX
YoY Member Change % =
VAR SelectedSnapshotYear = SELECTEDVALUE('DPMLY Snapshots'[SnapshotYear])
VAR SelectedCohort = SELECTEDVALUE('DPMLY Snapshots'[Actdate])
-- Current year member count
VAR CurrentMcount =
CALCULATE(
MAX('DPMLY Snapshots'[Mcounts]),
FILTER(
'DPMLY Snapshots',
'DPMLY Snapshots'[SnapshotYear] = SelectedSnapshotYear &&
'DPMLY Snapshots'[Actdate] = SelectedCohort &&
'DPMLY Snapshots'[Snapshotdate] =
CALCULATE(
MAX('DPMLY Snapshots'[Snapshotdate]),
FILTER(
'DPMLY Snapshots',
'DPMLY Snapshots'[SnapshotYear] = SelectedSnapshotYear &&
'DPMLY Snapshots'[Actdate] = SelectedCohort
)
)
)
)
-- Previous year member count
VAR PrevMcount =
CALCULATE(
MAX('DPMLY Snapshots'[Mcounts]),
FILTER(
'DPMLY Snapshots',
'DPMLY Snapshots'[SnapshotYear] = SelectedSnapshotYear - 1 &&
'DPMLY Snapshots'[Actdate] = SelectedCohort &&
'DPMLY Snapshots'[Snapshotdate] =
CALCULATE(
MAX('DPMLY Snapshots'[Snapshotdate]),
FILTER(
'DPMLY Snapshots',
'DPMLY Snapshots'[SnapshotYear] = SelectedSnapshotYear - 1 &&
'DPMLY Snapshots'[Actdate] = SelectedCohort
)
)
)
)
RETURN
IF(
NOT ISBLANK(CurrentMcount) && NOT ISBLANK(PrevMcount),
DIVIDE(CurrentMcount - PrevMcount, PrevMcount, 0),
BLANK()
)
bhanu_gautam : this is the error i am getting. The MAX function only accepts a column reference as an argument.
below is the logic i am using to achive member counts .
Membercount = CALCULATE(DISTINCTCOUNT('DPMLY Snapshots'[ACTid]),'DPMLY Snapshots'[Member Flag]>=1)
Member Flag = CALCULATE(DISTINCTCOUNT('DPMLY Snapshots'[ACTid]), ALLEXCEPT('DPMLY Snapshots','DPMLY Snapshots'[Snapshot_DateID],'DPMLY Snapshots'[ACTid]),
'DPMLY Snapshots'[AccountStatus]="Open",'DPMLY Snapshots'[Prodcode]="1" ,ISBLANK('DPMLY Snapshots'[ChargeOffDate]),ISBLANK('DPMLY Snapshots'[CloseDate]))