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
DCrone
Frequent Visitor

Issues with creating a single table with multiple constraints

I am trying to recreate a report that has separate filters, in a single table. The first calculate statement works as expected, but I need the second to aggregate all the listed values and place them only on department "155".

The logic being:
For departments "011" through "154", sum the accounts between "4700" and "4705"
For departments "011" through "155", sum the accounts between "4740" and "4741" and aggregate to a single value of department "155"


I've tried to use IF statements, SWITCH statements, but it always shows an error saying column not found. When I attempt to use ALL(), it aggregates it correctly, but I cant isolate the it to just show on row department "155". I'm sure there is a best practice for this, but I can't figure it out.

 

 

Retail Income =
CALCULATE(
    SUM(generalLedgerEntries[amount]) * -1,
    dimensionValues[Department Number] >= "011" && dimensionValues[Department Number] <= "029" ||
    dimensionValues[Department Number] >= "040" && dimensionValues[Department Number] <= "154",
    generalLedgerEntries[accountNumber] >= "4700" && generalLedgerEntries[accountNumber] <= "4705"
)

+

CALCULATE(
    SUM(generalLedgerEntries[amount]) * -1,
    generalLedgerAccounts[accountNumber] >= "4740" && generalLedgerAccounts[accountNumber] <= "4741",
    dimensionValues[Department Number] >= "011" && dimensionValues[Department Number] <= "155"
)

 

 

Using ALL gives me the correct value for row department "155", but departments "011" through "154" also adds it to each associated department giving me incorrect results. I can't seem to return the value for specifically department "155"
 

 

CALCULATE(
    SUM(generalLedgerEntries[amount]) * -1,
    ALL(dimensionvalues),
    generalLedgerAccounts[accountNumber] >= "4740" && generalLedgerAccounts[accountNumber] <= "4741",
    dimensionValues[Department Number] >= "011" && dimensionValues[Department Number] <= "155"
)

 

 

Picture to explain the logic more clearly
DCrone_1-1739211406441.png
3 REPLIES 3
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

DepartmentSum accounts 4700-4705Sum accounts 4740 - 4741Expected Output

011

20015200
01330010300
01430020300
01525025250
01715010150
155 580660

 

Above is sample data to illustrate what I am trying to achieve. The expected output consists of departments 011-154 containing their respective total sum of accounts 4700-4705, while for department 155, I want to sum the entire column of accounts 4740-4741 and have it displayed on department 155.

 

660 in this example is the sum of all the accounts 4740-4741 inclusive of department 155's value where as all the other values are just the sum of the accounts 4700-4705.

Hi,

This calculated column formula works

Column = if(AND(1*Data[Department]>=11,1*Data[Department]<=17),Data[Sum accounts 4700-4705],SUM(Data[Sum accounts 4740 - 4741]))

Hope this helps.

Ashish_Mathur_0-1739241063690.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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