pivot on account tags, is it possible

6 views
Skip to first unread message

Laurenz Wiskott

unread,
Oct 6, 2021, 4:17:42 PMOct 6
to hledger
Hi there, I am new to this forum, so I don't know whether I am right here. Anyhow, here is my question:

I just came across the --pivot feature and find it quite neat. I would like to use this feature to group account in different ways that would not be convenient to code into the account names.  So here is one version that works for me with hledger 1.20.99

'''
2021-01-25 in
    testA1                                                                   100 EUR ; class: A
    input
   
2021-01-25 in
    testA2                                                                   100 EUR ; class: A
    input
   
2021-01-25 in
    testB1                                                                   100 EUR ; class: B
    input
   
2021-01-25 in
    testB2                                                                   100 EUR ; class: B
    input
'''
  
linux> hledger -f pivot1.ledger bal --pivot class

gives the desired result

            -400 EUR 
             200 EUR  A
             200 EUR  B
--------------------
                   0 

But this requires to add 'class: A' and 'class: B' to every transaction.  I would prefer if it were possible on an account basis. But I did not get this to work. Here is a failure example:

'''
account testA1  ; class: A
account testA2  ; class: A
account testB1  ; class: B
account testB2  ; class: B

2021-01-25 in
    testA1                                                                   100 EUR
    input
   
2021-01-25 in
    testA2                                                                   100 EUR
    input
   
2021-01-25 in
    testB1                                                                   100 EUR
    input
   
2021-01-25 in
    testB2                                                                   100 EUR
    input
'''
  
linux> hledger -f pivot1.ledger bal --pivot class

does not give the desired result

--------------------
                   0 

I have played around with different variants of that, but without success. Anybody has a hint how to get this to work.

Laurenz.

Simon Michael

unread,
Oct 6, 2021, 4:20:00 PMOct 6
to hledger
Hi Laurenz, welcome. This is a good thought, but it has not been implemented yet, unfortunately. It's the next task at https://github.com/simonmichael/hledger/issues/217 .



--
You received this message because you are subscribed to the Google Groups "hledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hledger+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/hledger/23be950c-7c2e-43f7-be1f-c35baf399967n%40googlegroups.com.

Simon Michael

unread,
Oct 6, 2021, 4:44:05 PMOct 6
to hledger
Though for this particular example, you can achieve something similar by using account aliases:

$ hledger bal --alias /testA./=A --alias /testB./=B




Laurenz Wiskott

unread,
Oct 6, 2021, 5:01:28 PMOct 6
to hledger
Great, thank you for the hint with the alias. I will play with that and see how far I'll get.

Thanks for this great program. 
Reply all
Reply to author
Forward
0 new messages