Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ronaldbalza2023
Continued Contributor
Continued Contributor

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

ronaldbalza2023_0-1632577349878.png

ronaldbalza2023_1-1632577375606.png

 

With Tracking Categories - most of columns were zero values.

ronaldbalza2023_3-1632577862341.pngronaldbalza2023_4-1632577878772.png

 

 

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 2
Greg_Deckler
Super User
Super User

@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.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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)

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.