Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello,
I need help with creating a sum if formula where if "Margin Account Y/N?" column C is equal to "Y" then sum the values in column B "Margin Balance USD" by column A "Facility Code".
Therefore, facility code 88888 should sum to $8,440,538 since there are two rows of data/values.
Hello @123abc ,
Thank you for the reply but I do not need this in excel, I need the formula done in Power BI. Also, I should mention that column B and C are calculated columns and not the original columns in the data.
To create a SUMIF formula in Power BI where you want to sum values in column B ("Margin Balance USD") based on a condition in column C ("Margin Account Y/N?"), you can use DAX (Data Analysis Expressions) functions. In Power BI, this can be achieved using the SUMX function in combination with FILTER. Here's how you can create the measure:
Open Power BI Desktop and load your data into the data model.
In the "Model" view, click on "New Measure" in the "Modeling" tab to create a new measure.
In the formula bar that appears, enter the following DAX formula:
Total Margin Balance USD =
SUMX(
FILTER(
YourTableName, // Replace 'YourTableName' with the actual name of your table
YourTableName[Margin Account Y/N?] = "Y"
),
YourTableName[Margin Balance USD]
)
Make sure to replace 'YourTableName' with the actual name of your table that contains the data.
Press Enter to create the measure. This measure will calculate the sum of "Margin Balance USD" where the "Margin Account Y/N?" column equals "Y."
Now, you can add this measure to a visual, such as a card or table, to display the total margin balance for rows where "Margin Account Y/N?" is equal to "Y."
Here's how you can add this measure to a table:
The table should now display the sum of "Margin Balance USD" for each "Facility Code" where "Margin Account Y/N?" is equal to "Y."
In your example, if there are two rows with "Facility Code" 88888 and "Margin Account Y/N?" equal to "Y," the total margin balance for that code will be displayed as $8,440,538.
You can achieve this using the SUMIFS function in Excel to sum values in Column B based on the criteria in Column C and Column A. Here's how you can create the formula:
Assuming your data is in columns A, B, and C, and you want to calculate the sum of "Margin Balance USD" (Column B) where "Margin Account Y/N?" (Column C) is equal to "Y," and group the results by "Facility Code" (Column A), you can use the following formula:
```excel
=SUMIFS(B:B, C:C, "Y", A:A, A2)
```
Here's a breakdown of the formula:
- `B:B`: This is the range containing the values you want to sum (Column B).
- `C:C`: This is the range containing the criteria you want to check (Column C).
- `"Y"`: This is the criteria you're looking for in Column C.
- `A:A`: This is the range containing the criteria you want to group by (Column A).
- `A2`: This is the specific Facility Code you want to match for the current row in your calculation. You can place this formula in another column (e.g., Column D) and copy it down for each row in your dataset.
After you've placed the formula in a new column (e.g., Column D), it will calculate the sum of "Margin Balance USD" for each Facility Code where "Margin Account Y/N?" is equal to "Y." Copy the formula down for each unique Facility Code, and you'll get the desired sums. In your example, you'll get $8,440,538 for Facility Code 88888.
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
90 | |
87 | |
84 | |
66 | |
49 |
User | Count |
---|---|
131 | |
110 | |
96 | |
70 | |
67 |