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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
DaveAng
New Member

Help with ignoring row context

Hi!

 

I have two tables; One dimension with accounting codes and one fact table with transactions. 

I did an easy sum on the transactions like this: 

 

Total = SUM(Fact_table[AccountingAmount])
 
But I want to show all accounts, even if there are no transactions. This is the measure that I created:
 
Total_all_accounts =
IF (
    [Total] = BLANK (),
    0 + 'Measures Table'[Total],
    [Total]
)
 
This is the result, and also the result i wanted. So far so good:
DaveAng_0-1677142889104.png

But it is now when things are starting to get tricky for me. I want the sum of a specific range of accounts to be summarized in account no 1099. First I did a measure to define the accounts that should be included (1010-1098). Since the data type of the Account is text I used FORMAT:

 

1099 =
CALCULATE(
                [Total_all_accounts],
                FILTER(DimAccounting,
                DimAccounting[Account] >= FORMAT(1010, "Fixed")
                && DimAccounting[Account] <= FORMAT(1098, "Fixed")
            ))
 
When I use the measure in a card visualization I get the result I want. Then I tried to put it all together. I want the measure to display [Total_all_accounts] on every row except for the account 1099, where the measure [1099] should be displayed. Here is the measure I created :
 
Total_test =
VAR Account =
   SELECTEDVALUE (DimAccounting[Account])
RETURN
    SWITCH (
        Account,
        "1099",
        [1099]  ,
        [Total_all_accounts]
        )
   
And here is the result:
DaveAng_1-1677144445575.png

[Total_test] give me the same result as [Total_all_accounts], but I want the sum of accounts 1010-1098 on the 1099 account. My best guess is that's because of row context. I hope someone can help me with my issue and show me how to ignore row context on 1099 (or if I made some other misstakes in the previous steps). 

 

Thanks!

 

Best regards

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

Hi @DaveAng ,

 

Please try.

Total_all_accounts = [Total] + 0
1099 =
SUMX (
    FILTER (
        ALL ( 'Dim_Table' ),
        'Dim_Table'[Account] >= "1010"
            && 'Dim_Table'[Account] <= "1098"
    ),
    [Total_all_accounts]
)
Total_test = 
SWITCH(
    SELECTEDVALUE('Dim_Table'[Account]),
    "1099",
    [1099],
    [Total_all_accounts]
)

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

2 REPLIES 2
v-cgao-msft
Community Support
Community Support

Hi @DaveAng ,

 

Please try.

Total_all_accounts = [Total] + 0
1099 =
SUMX (
    FILTER (
        ALL ( 'Dim_Table' ),
        'Dim_Table'[Account] >= "1010"
            && 'Dim_Table'[Account] <= "1098"
    ),
    [Total_all_accounts]
)
Total_test = 
SWITCH(
    SELECTEDVALUE('Dim_Table'[Account]),
    "1099",
    [1099],
    [Total_all_accounts]
)

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Hi,

 

Thank you! Your solution worked just fine!

 

BR

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!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.