Forum Discussion

AK_BA's avatar
AK_BA
Frequent Visitor
7 years ago
Solved

DAX Union with SelectColumns

Hi - I am new to Power BI (coming from years with MSSQL and SSRS) and have a question regarding utilizing a combination of Union, SelectColumns and First/LastNonBlank.

 

Background

I have been tasked with developing a report that calculates financial factors as well as IRR (XIRR to be specific).  XIRR requires a data set that combines two of my data sets:

  1. Cashflow data:  XIRR dataset needs all cashflows that fall between dates from my date slicer (custom auto DateDim)
  2. Valuation data:  If there is a beginning date that matches the min date on my slider, I need to get the beginning value.  Ending value is the exact opposite

Where I'm At

  • I have all my datasets set up with proper relationships (they filter based on fund and my time slider just fine).
  • I have a custom table started to UNION these datasets together
  • I have a custom table TimeDim = CALENDARAUTO(), with MaxDate and MinDate measures

My Issue

I'm having a hard time combining just the first and last records from the valuation table with my cashflow table.  I've tried making measures to capture this data, I've tried Frist/LastNonBlank, Calculate, and LookupValues with varying results (none of which actually met my requirements).

 

My Custom Table code:

 

ReturnData = SELECTCOLUMNS(vwCashflows,"dt",vwCashflows[EffectiveDate],"amt",vwCashflows[CashflowAmount],"secId",vwCashflows[SecurityId])

I had a UNION prior to removing the other selectedcolumns because they weren't bringing back good results.

 

 

Here is an example of my filtered data:

The combined table should have a 595,139.50 entry for 1/1/2017 and a 260,552.97 entry for 12/31/2018.  Any guidance you can give to get me on the right track would be appreciated.  My guess is that this is something simple I just haven't learned or run across yet.

 

Thanks for any help you can provide!

7 Replies

  • Hi,

    I am  not sure of how much i can help but i'd like to try.  Share both tables in a format that can be pasted in Excel.  Also, is "Net capital", the "Ending NAV"?

    • AK_BA's avatar
      AK_BA
      Frequent Visitor

      Thank you Ashish - The valuation and cashflow data can be found here and here.

       

      Net capital in this case is Ending NAV.

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        This is the result i have got but am not very confident.  So please share data for 2 securities and let me know what slicers/filters do you want to apply.  Please also clearly show the expected result.