Forum Discussion
Inferring Missing Columns and Imputing Missing Data
- 4 months ago
Hi liveincolorado,
Thank you for the update.
Total Balance =
VAR MonthStart = MIN('Date'[Date])
VAR MonthEnd = MAX('Date'[Date])RETURN
SUMX(
VALUES(Accounts[ACCT_ID]),VAR LatestDate =
CALCULATE(
MAX(Accounts[CLI_START_DT]),
FILTER(
Accounts,
Accounts[ACCT_ID] = EARLIER(Accounts[ACCT_ID]) &&
Accounts[CLI_START_DT] <= MonthEnd
)
)VAR Balance =
CALCULATE(
MAX(Accounts[TOTAL_BALANCE]),
Accounts[CLI_START_DT] = LatestDate
)VAR IsActive =
CALCULATE(
COUNTROWS(Accounts),
FILTER(
Accounts,
Accounts[ACCT_ID] = EARLIER(Accounts[ACCT_ID]) &&
Accounts[CLI_START_DT] <= MonthEnd &&
COALESCE(Accounts[CLI_END_DT], DATE(9999,12,31)) >= MonthStart &&
Accounts[SA_START_DT] <= MonthEnd &&
COALESCE(Accounts[SA_END_DT], DATE(9999,12,31)) >= MonthStart
)
)RETURN
IF(IsActive > 0, Balance)
)Thankyou.
Hi liveincolorado,
I've created the sample .pbix file for you with DAX for all the three columns.
Active Accounts =
VAR StartDate = MIN('Date'[Date])
VAR EndDate = MAX('Date'[Date])
RETURN
CALCULATE(
DISTINCTCOUNT(Accounts[ACCT_ID]),
FILTER(
Accounts,
-- CLI condition
Accounts[CLI_START_DT] <= EndDate &&
COALESCE(Accounts[CLI_END_DT], DATE(9999,12,31)) >= StartDate &&
-- SA condition
Accounts[SA_START_DT] <= EndDate &&
COALESCE(Accounts[SA_END_DT], DATE(9999,12,31)) >= StartDate
)
)Total Balance =
VAR EndDate = MAX('Date'[Date])
RETURN
SUMX(
VALUES(Accounts[ACCT_ID]),
VAR LatestRow =
CALCULATE(
MAX(Accounts[CLI_START_DT]),
FILTER(
Accounts,
Accounts[ACCT_ID] = EARLIER(Accounts[ACCT_ID]) &&
Accounts[CLI_START_DT] <= EndDate
)
)
VAR Balance =
CALCULATE(
MAX(Accounts[TOTAL_BALANCE]),
Accounts[CLI_START_DT] = LatestRow
)
VAR IsActive =
CALCULATE(
COUNTROWS(Accounts),
FILTER(
Accounts,
Accounts[ACCT_ID] = EARLIER(Accounts[ACCT_ID]) &&
Accounts[CLI_START_DT] <= EndDate &&
COALESCE(Accounts[CLI_END_DT], DATE(9999,12,31)) >= EndDate &&
Accounts[SA_START_DT] <= EndDate &&
COALESCE(Accounts[SA_END_DT], DATE(9999,12,31)) >= EndDate
)
)
RETURN IF(IsActive > 0, Balance)
)
Avg Payoff Balance =
DIVIDE(
[Total Balance],
[Active Accounts]
)
Please see attached file.
๐ I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
๐ก Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
๐ As a proud SuperUser and Microsoft Partner, weโre here to empower your data journey and the Power BI Community at large.
๐ Curious to explore more? [Discover here].
Letโs keep building smarter solutions together!
Hi liveincolorado,
Did you try this solution? if it works kindly mark as accepted soltution, if not let me know the challange you are facing