Forum Discussion
Power BI Formula: Sum if - 3 columns
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:
- Create a table visual in your report.
- In the "Values" section of the table visual, drag and drop the "Total Margin Balance USD" measure you just created.
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.