Forum Discussion

ronaldbalza2023's avatar
ronaldbalza2023
Continued Contributor
4 years ago

Repeating Amount - DAX Measure

I have 5 tables (Invoices,Credit Notes,Journals,Accounts & Tracking Categories) that are connected with each other with the following DAX measures below. 

 

Now, when I bring the tracking categories as column, it gives me a weird calculation with most of the columns have zero values on them. 

 

Without Tracking Categories - Works fine

 

With Tracking Categories - most of columns were zero values.

 

 

Dax Measures

P&L = 
CALCULATE (
    SUM ( 'Invoices'[Line Amount Calculation] ),
    FILTER (
        'Accounts',
        Accounts[Class] = "Revenue"
            || Accounts[Class] = "Expense"
    )
) - [P&L - Credit Notes] + [P&L (Journals)]

 

P&L - Credit Notes = 
CALCULATE (
    SUM ( 'Credit Notes'[Line Amount Credit Note Calculation] ),
    FILTER (
        'Accounts',
        Accounts[Class] = "Revenue"
            || Accounts[Class] = "Expense"
    )
)

 

P&L (Journals) = 
CALCULATE (
    0 - ( SUM ( 'Journals'[Net Amount] ) ),
    FILTER ( 'Journals', 'Journals'[Split] = "JOURNALS" ),
    FILTER (
        'Accounts',
        Accounts[Class] = "Revenue"
            || Accounts[Class] = "Expense"
    )
)

 

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    ronaldbalza2023 Sorry, having trouble following, can you post sample data as text and expected output?
    Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

    Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.

    • ronaldbalza2023's avatar
      ronaldbalza2023
      Continued Contributor

      Hi Greg_Deckler ,thanks for taking the time on this.  Here you go. 

      1. Sample Data

      Accounts Table

      Account TypeNameAccount_UID
      RevenueSales1
      RevenueSales2
      RevenueInterest Income3
      RevenueInterest Income4
      Direct CostsClient Gifts5
      Direct CostsClient Gifts6
      Direct CostsSalary & Wages7
      Direct CostsSalary & Wages8
      ExpensesBank Fees9
      ExpensesBank Fees10
      ExpensesMotor Vehicles11
      ExpensesMotor Vehicles12
      ExpensesOffice Expenses13
      ExpensesOffice Expenses14

       

      Invoices Table

      Line Amount CalculationAccount_UIDTracking Categories_ID
      $6,00011
      $1,50022
      $25031
      $10042
      $40051
      $5062
      $1,00071
      $20082
      $40091
      $200102
      $500111
      $150122
      $250131
      $0142

       

      Journals Table

      Net AmountAccount_UIDTracking Categories_ID
      $1,50011
      $2,00022
      $1,50031
      $20042
      $10051
      $5062
      $1,50071
      $1,50082
      $5091
      $50102
      $500111
      $850122
      $100131
      $250142

       

      Credit Notes Table

      Line Amount Credit Note CalculationAccount_UIDTracking Categories_ID
      $50011
      $1,00022
      $25031
      $20042
      $051
      $10062
      $071
      $10082
      $5091
      $0102
      $0111
      $0122
      $150131
      $0142

       

      Tracking Categories

      Tracking Categories_IDName
      11 Marquis
      21 Yabtree

       

      2. Expected Output

      Account Type1 Marquis1 Yabtree
          + Revenue$ 10,000$ 5,000
                Sales$ 8,000$ 4,500
                Interest Income$ 2,000$ 500
          + Direct Costs($ 3,000)($ 2,000)
                Client Gifts($ 500)($ 200)
                Salary & Wages ($ 2,500)($ 1,800)
          + Expenses($ 2,000)($ 1,500)
                Bank Fees($ 500)($ 250)
                Motor Vehicles($ 1,000)($ 1,000)
                Office Expenses($ 500)($ 250)
      Total$ 5,000$ 1,500

       

      3. Invoices Table, Credit Notes Table, Journals Table are connected with Accounts Table using Account_UID column. (many to one)

      Invoices Table, Credit Notes Table, Journals Table are connected with Tracking Categories Table using Tracking Categories_ID column (many to one)