Forum Discussion

Alfredowoo's avatar
Alfredowoo
Frequent Visitor
2 years ago
Solved

LOAN DISBURSEMENT AND REPAYMENTS

I need some help with the attached dataset. This is a smaller version of the dataset the original one is over 13 million rows I have a date table with the date linked to the transaction date in the ...
  • parry2k's avatar
    2 years ago

    Alfredowoo Yes there was no solution but I wanted to confirm if that is what you are expecting as an output, simple confirmation could help avoid this back and forth. 

     

    Anyhow, here are the measures you can test in your model. Keep in mind these measures can be collapsed in the final measure but I prefer to have them seperate so they can be reused and also help to debug the issues:

     

    Sum Amount = SUM (fData[TransactionAmount] )
    
    Disbursement Amount = CALCULATE ( [Sum Amount], fData[TransactionType] = "Disbursement" )
    
    Collections Amount = CALCULATE ( [Sum Amount], fData[TransactionType] IN { "Principal_Repayment", "Interest_Fee_Repayment" } )
    
    
    Count = 
    VAR __baseTable =
        ADDCOLUMNS (
            VALUES ( fData[LoanId] ),
            "@Disbursement Amount", [Disbursement Amount],
            "@Collections Amount", [Collections Amount] 
        )
    VAR __AddDefaultedFlag = 
    ADDCOLUMNS (
        __baseTable,
        "@Defaulted",
        ISBLANK ( [@Collections Amount] ) || [@Collections Amount] < [@Disbursement Amount]
    )
    RETURN
    COUNTROWS ( FILTER ( __AddDefaultedFlag, [@Defaulted] ) )

     

    One piece of advice here is that it will be better if you have a separate dimension for the loan table, basically all the attributes of each loan in a separate table, and it will be have a unique row for each loan record.  This table will have a relationship with fdata table on loanid and the above measure will then use loanid from this new table, and also in the visualization you will pick loan related columns from this table.  

     

    It is a better model and will follow the best practice, and that will provide better performance.