0

Trying to find a solution (pivot view??)

I have a simple trading journal database. My main form collects initial trade data with opening "trade date". I have a sub-form in that form to collect data for any further adjustments to that particular trade.

My problem:  Generate a chart or field that  summarizes ALL my generated income for a given day (ie "Total Premium" from main form AND any generated "Roll Premium" from the sub-form)

When I try a pivot, I'm unable to get both sets of data into it. When trying to generate a field to calculate the data, I'm unable to figure out proper formula. 

I have successfully and happily created all the other main metrics I need for the database except this one. Any help would be immensely appreciated. 

 

14 replies

null
    • Fred
    • 11 mths ago
    • Reported - view

    I can't make a comment on pivot tables, but to get values from your child table is easy.

    At the parent level, you can create a formula field, we can call it 'Total Roll Premium', with:

    sum('Close or Roll Data'.'Roll Premium')
    

    Then another formula to add the two fields together:

    'Total Premium' + 'Total Roll Premium'
    
    • Rick_Castellini
    • 11 mths ago
    • Reported - view

    Thanks for your reply. Yes, I have that field created and it works great. However, I'm looking to get ONLY the sub-table data that matches a specific date. Any ideas?    

    • Fred
    • 11 mths ago
    • Reported - view

    To filter reference links you would use the double brackets [ ].

    If we use your pics from the original post then I guess it would look something like:

    let t := this;
    sum('Close or Roll Data'['Close or Roll' = t.'Trade Date'].'Roll Premium')
    

    But first you need to gather the current record into a variable using the 'this' function.

    Then you can you use that variable to reference any field in the parent record.

    I can only see the column name 'Close or Roll', so I don't know if that is the full name. Please modify it with the full name if needed.

    • Rick_Castellini
    • 11 mths ago
    • Reported - view

    Thanks!! I'm trying to understand this scripting, but keep running into road blocks. Based on your answer, I get the following errors:

    • Fred
    • 11 mths ago
    • Reported - view

    Why did you add the select command in there? We are using the reference link to get your data. With more info here is what it should look like:

    let t := this;
    sum('Close or Roll Data'['Close or Roll Date' = t.'Trade Date'].'Roll Premium')

    For educational purposes we can troubleshoot the image.

    The reason you are getting the error is because  you don't have a reference field called 'Closed-Roll Data' in your table 'Closed-Roll Data'.

    • Rick_Castellini
    • 11 mths ago
    • Reported - view

    REALLY appreciate your help with this!!!

    I thought I needed to use the "select" to get the data since it didn't work without it either. 

    Entered the code you suggested and get this error:

    • Fred
    • 11 mths ago
    • Reported - view

    Oops, I misread the initial image. Just change the 'Close or Roll Data' to match your field name 'Closed-Roll Data'.

      • Rick_Castellini
      • 11 mths ago
      • Reported - view

       My bad as well...should have seen that. GREAT, the formula enters with no error. BUT, it gives me only "0" as an answer. Here is an example of where the total should be 2.38 + the value of the other record for the date. 

      If you aren't sick of helping a newbie, I would really appreciate it. I THINK I understand the first statement you built for me. I'm heading to a meeting, but will check the forum later. THANK YOU!! THANK YOU!!!

      • Fred
      • 11 mths ago
      • Reported - view

      From your picture, the 'Trade Date' is 04/01/2023 in the top right side of the image. I don't know what 'Trade Date' you are showing in the table view on the left side of the image.

      I think once you solve that then things will work like you expect.

      • Rick_Castellini
      • 11 mths ago
      • Reported - view

       Thanks Fred. The "Trade Date" in my Trade Details table  (and in the "Income by Day" view I'm trying to create) is the "opening date" of a NEW trade. I guess, a new trade can be like a new customer. Sometimes the trades stand alone and expire without further "sales", but other times, I need to manage those trades which is what the "Closed-Roll Data" table is. They can be like "sales" to the "customer" (original trade). 

      What I'm trying to gather is all my work for a give day. In the example above, I had other "new customers" (opening trades) that generated income AND old customers that I made sales to (the Closed-Roll Data entries).  I can get new income easily by totaling the "Total Premium" in the Trade Details table and grouping by date, but cannot get the total premium from the sub-tables by date. 

      I can't understand why I can't solve this more easily. Your help is getting me closer though!

    • Fred
    • 11 mths ago
    • Reported - view
     said:
    The "Trade Date" in my Trade Details table  (and in the "Income by Day" view I'm trying to create) is the "opening date" of a NEW trade.

    I don't see a field called "opening date" in the Trade Details table. I don't know where that 05/10/2023 date is coming from since it does not show up in the Trade Detail form view.

    In your table view for Trade Detail table where is the data for the Trade Date column coming from? Was this column name changed from the default?

    You have to match the correct fields. It looks like you want to find records in Closed-Roll Data that matches 05/10/2023, but the field called Trade Date has data of 04/03/2023. You need to figure out this difference.

    • Rick_Castellini
    • 11 mths ago
    • Reported - view

    Back to it today, and I created a new formula field in the sub-table and can get my "income by day" for the sub-table. Already able to get income by day from main table (trade details as above). Why is there not a way to easily combine these two???

    The third screenshot shows my attempt at including the newly created sub-table field, but it will only give me the info for individual trades on a matching date which makes me have to manually calculate what really went on for the whole day. Also when adding a sub-table field, why only the choices of first, last, min, max, etc??

    Ninox being a relational database, I would think creating reports that allowing querying of data and displaying that data in reports or charts would be easier. I've watched the tutorials many times and am working to understand the scripting, but I'm still missing a huge piece of understanding here. Thanks again for help and feedback (especially  )

    • Fred
    • 11 mths ago
    • Reported - view
     said:
    Why is there not a way to easily combine these two???

    You just need to follow my comments from earlier replies. If you are in Trade Details table then you can create the following formula field:

    sum('Rolls-Closed Details'.TRollPremium) + 'IncomefieldName'

    Also when adding a sub-table field, why only the choices of first, last, min, max, etc??

    That is because you are trying to add data from a table that has could have many records. So Ninox asks how you want to deal with that issue. Do you want to show the first, last, min, max, or concatenate?

    I would think creating reports that allowing querying of data and displaying that data in reports or charts would be easier.

    One trick is to start using dashboards to do your data mining. I found trying to make views in the raw data tables was a frustrating and hopeless endeavor.

      • Rick_Castellini
      • 11 mths ago
      • Reported - view

       Yes, I'm trying to learn the Dashboard now as well...still not super intuitive for me. I really like Google DataStudio for it's ability to take data and massage into nice dashboards. But I'm super impressed with Ninox's setup, I just need to deep dive into it and maximize what it has. It has launched me far and above my Google Sheets solution I was using.

      Thanks again.

Content aside

  • 11 mths agoLast active
  • 14Replies
  • 126Views
  • 2 Following