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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Aslam_mh
Frequent Visitor

problem in DAX calculation total and subtotals

preview-balance.png

want to output like attached photo but shows error when i calculate grand total using 2 DAX funtions

for display im using balancesheeet table templet

Row IndexBalance Sheet ItemsSummary ItemsBalance Sheet NormalizedSummary Index
1Assets Assets 
2          Current Assets Current Assets 
3                    Cash Cash 
4                    Accounts receivable Accounts receivable 
5                    Inventory Inventory 
6                    Prepaid expenses Prepaid expenses 
7                    Short-term investments Short-term investments 
8                                                            Total current assetsTotal current assetsTotal current assets1
9          Fixed (Long-Term) Assets Fixed (Long-Term) Assets 
10                    Long-term investments Long-term investments 
11                    Property, plant, and equipment Property, plant, and equipment 
12                    (Less accumulated depreciation) (Less accumulated depreciation) 
13                    Intangible assets Intangible assets 
14                                                            Total fixed assetsTotal fixed assetsTotal fixed assets2
15          Other Assets Other Assets 
16                    Deferred income tax Deferred income tax 
17                    Other Other 
18                                                            Total Other AssetsTotal Other AssetsTotal Other Assets3
19    
20          Total AssetsTotal AssetsTotal Assets4




for data balance sheet data

Balance Sheet TypeCategorySub CategoryYearValues
AssetsCurrent AssetsCash201911874
AssetsCurrent AssetsCash202011875
AssetsCurrent AssetsCash202111876
AssetsCurrent AssetsCash202211877
AssetsCurrent AssetsCash202311879
AssetsCurrent AssetsAccounts receivable20194215
AssetsCurrent AssetsAccounts receivable20204216
AssetsCurrent AssetsAccounts receivable20214217
AssetsCurrent AssetsAccounts receivable20224218
AssetsCurrent AssetsAccounts receivable20234220
AssetsCurrent AssetsInventory20192145
AssetsCurrent AssetsInventory20202146
AssetsCurrent AssetsInventory20212147
AssetsCurrent AssetsInventory20222148
AssetsCurrent AssetsInventory20232150
AssetsCurrent AssetsPrepaid expenses2019354
AssetsCurrent AssetsPrepaid expenses2020355
AssetsCurrent AssetsPrepaid expenses2021356
AssetsCurrent AssetsPrepaid expenses2022357
AssetsCurrent AssetsPrepaid expenses2023359
AssetsCurrent AssetsShort-term investments2019254
AssetsCurrent AssetsShort-term investments2020255
AssetsCurrent AssetsShort-term investments2021256
AssetsCurrent AssetsShort-term investments2022257
AssetsCurrent AssetsShort-term investments2023259
AssetsFixed (Long-Term) AssetsLong-term investments20191208
AssetsFixed (Long-Term) AssetsLong-term investments20201209
AssetsFixed (Long-Term) AssetsLong-term investments20211210
AssetsFixed (Long-Term) AssetsLong-term investments20221211
AssetsFixed (Long-Term) AssetsLong-term investments20231213
AssetsFixed (Long-Term) AssetsProperty, plant, and equipment201915340
AssetsFixed (Long-Term) AssetsProperty, plant, and equipment202015341
AssetsFixed (Long-Term) AssetsProperty, plant, and equipment202115342
AssetsFixed (Long-Term) AssetsProperty, plant, and equipment202215343
AssetsFixed (Long-Term) AssetsProperty, plant, and equipment202315345
AssetsFixed (Long-Term) Assets(Less accumulated depreciation)2019-2200
AssetsFixed (Long-Term) Assets(Less accumulated depreciation)2020-2199
AssetsFixed (Long-Term) Assets(Less accumulated depreciation)2021-2198
AssetsFixed (Long-Term) Assets(Less accumulated depreciation)2022-2197
AssetsFixed (Long-Term) Assets(Less accumulated depreciation)2023-2195
AssetsFixed (Long-Term) AssetsIntangible assets20192215
AssetsFixed (Long-Term) AssetsIntangible assets20202216
AssetsFixed (Long-Term) AssetsIntangible assets20212217
AssetsFixed (Long-Term) AssetsIntangible assets20222218
AssetsFixed (Long-Term) AssetsIntangible assets20232220
AssetsOther AssetsDeferred income tax2019134
AssetsOther AssetsDeferred income tax2020135
AssetsOther AssetsDeferred income tax2021136
AssetsOther AssetsDeferred income tax2022137
AssetsOther AssetsDeferred income tax2023139
AssetsOther AssetsOther2019324
AssetsOther AssetsOther2020325
AssetsOther AssetsOther2021326
AssetsOther AssetsOther2022327
AssetsOther AssetsOther2023329
LiabilitiesCurrent LiabilitiesAccounts payable20198060
LiabilitiesCurrent LiabilitiesAccounts payable20208061
LiabilitiesCurrent LiabilitiesAccounts payable20218062
LiabilitiesCurrent LiabilitiesAccounts payable20228063
LiabilitiesCurrent LiabilitiesAccounts payable20238065
LiabilitiesCurrent LiabilitiesShort-term loans2019200
LiabilitiesCurrent LiabilitiesShort-term loans2020201
LiabilitiesCurrent LiabilitiesShort-term loans2021202
LiabilitiesCurrent LiabilitiesShort-term loans2022203
LiabilitiesCurrent LiabilitiesShort-term loans2023205
LiabilitiesCurrent LiabilitiesIncome taxes payable20193145
LiabilitiesCurrent LiabilitiesIncome taxes payable20203146
LiabilitiesCurrent LiabilitiesIncome taxes payable20213147
LiabilitiesCurrent LiabilitiesIncome taxes payable20223148
LiabilitiesCurrent LiabilitiesIncome taxes payable2023

3150






 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


DAX funtions

B/S Values =
VAR CurrentItem = SELECTEDVALUE( 'Balance Sheet Template'[Balance Sheet Normalized] )

RETURN
SWITCH( TRUE(),
    CurrentItem = "Total current assets", [Current Assets],
    CurrentItem = "Total fixed assets", [FixedAssets],
    CurrentItem = "Total Other assets", [Other Assets],
    CurrentItem = "Total Assets", [Total Assets], --------------------- ERROR
    CurrentItem = "Total current liabilities", [Current Liabilities],
    CurrentItem = "Total long-term liabilities", [Long-Term Liabilities],
    CurrentItem = "Total owner's equity", [Owners Equity],
    CurrentItem = "Total Liabilities and Owner's Equity", [Liabilities and Owners Equity], ---------- ERROR  [Current Liabilities] +  [Long-Term Liabilities]  unable to fetch data-------
 
        CALCULATE( [BS Values], FILTER( 'Balance Sheet Data', 'Balance Sheet Data'[Sub Category] = CurrentItem )  ))




BS Values =
CALCULATE( SUM( 'Balance Sheet Data'[Values] ),
    TREATAS( VALUES( Dates[Year] ), 'Balance Sheet Data'[Year] ) )
Current Assets =
SUMX(
    FILTER(
        'Balance Sheet Data',
        'Balance Sheet Data'[Category] = "Current Assets" &&
        TREATAS( VALUES( Dates[Year] ), 'Balance Sheet Data'[Year] )
    ),
    'Balance Sheet Data'[Values]
)


Fixed Assets = SUMX( FILTER( 'Balance Sheet Data', 'Balance Sheet Data'[Category] = "Fixed (Long-Term) Assets" ), [BS Values] )

total asset can be get but some other calculation we can't use 
Total Assets =
SUMX (
    FILTER (
        'Balance Sheet Data',
        'Balance Sheet Data'[Category] IN {"Current Assets", "Fixed (Long-Term) Assets", "Other Assets"}
    ),
    'Balance Sheet Data'[Values]
)

DAX like ------- [total assets]/ [current asset]


solotion need to diplay result like shown in photo , please help
 












3 REPLIES 3
danextian
Super User
Super User

It would be easier for us to figure out what's causing the error if you shared a sanitized copy of your pbix for several reasons:

  • we will have to recreate each measure and we don't even know what exact formula you used
  • our calculations might not return an error

Also, your B/S Values references [Long-Term Liabilities] but you have ommitted that as well as the equity section.

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

DataNinja777
Super User
Super User

Hi @Aslam_mh ,

 

I recommend addressing the balance sheet subtotal using a chart of accounts mapping table instead of incorporating it directly into your fact table. You can create a hierarchical mapping table, where the smallest unit represents GL accounts, and the largest aggregates into financial statement lines, such as total assets or total liabilities and shareholders' equity.

Additionally, I suggest displaying assets as positive numbers and liabilities and equity as negative numbers. This approach allows you to verify that the balance sheet consistently balances (adds up to zero).

 

Mapping table like below will be used as a dimention table and then relationship will be created with your fact table.

 

With this approach, there’s no need to create a complex DAX formula. A simple SUM formula (or a cumulative SUM formula for transactional data) will be sufficient to achieve the desired result.

 

Row Index Hierarchy Level 3 Summary Index Hierarchy Level 2 Hierarchy Level 1
1 Cash 1 Current Assets Assets
2 Accounts receivable 1 Current Assets Assets
3 Inventory 1 Current Assets Assets
4 Prepaid expenses 1 Current Assets Assets
5 Short-term investments 1 Current Assets Assets
6 Long-term investments 2 Fixed (Long-Term) Assets Assets
7 Property, plant, and equipment 2 Fixed (Long-Term) Assets Assets
8 (Less accumulated depreciation) 2 Fixed (Long-Term) Assets Assets
9 Intangible assets 2 Fixed (Long-Term) Assets Assets
10 Deferred income tax 3 Other Assets Assets
11 Other 3 Other Assets Assets

 

Best regards,

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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