相关文章推荐
严肃的麻辣香锅  ·  java - security ...·  1 年前    · 
月球上的小摩托  ·  Error: Failed to ...·  1 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I need to create 2 SUMIFS columns in Power Bi with multiple criteria. One column will be "Per Charge Per month" to find the total charges with "Sum of Charge Amount", "charge bucket", "Type", and "Delivery Month Column" columns as criteria. The other column will have the same criteria but instead of "Sum Of charge Amount" column it will be the "Number Of Containers" column.

I used to do this in excel by using the SUMIFS formula.

This is the SUMIFS Formula in the "Per Charge Per Month" Column

=SUMIFS($D$2:$D$11,$G$2:$G$11,G2,$B$2:$B$11,B2,$C$2:$C$11,C2)

This is the SUMIFS Formula in the "Container Per Month" Column

=SUMIFS($E$2:$E$11,$G$2:$G$11,G2,$B$2:$B$11,B2,$C$2:$C$11,C2)

I have tried to make these columns in Power BI but I can't even create a SUMIF calculated column with just 1 criteria. I used to formula below to try create a column that shows the total number of containers in each month. But it just shows the number of containers in that row. I don't even know how I would add more criteria. Any advice would be really appreciated!

SUMIF Container Per Month = 
VAR vRowShippingMonth = 'Invoice Charges'[Shipping month]
Return
CALCULATE(
    SUM('Invoice Charges'[Number of Containers]),
    'Invoice Charges'[Shipping month] = vRowShippingMonth) 
                How about abstracting the problem like shown at stackoverflow.com/help/minimal-reproducible-example, or would that be a disproportionate effort? After all you are asking for voluntary help ...
– Peter
                Aug 5, 2022 at 21:00
                Hello @Spen820 please show us some efforts by sharing your code in power bi. Otherwise, It would be useless to bring the screenshots of your excel sheets into this platform. please work on this topic a little more, then if you can't solve, then we can make some advice here. Your effort is paramount here. Stay safe!
– Ozan Sen
                Aug 5, 2022 at 21:06
                Upload data and code as text please. Not as images.  Why should I not upload images of code/data/errors when asking a question?
– Ron Rosenfeld
                Aug 5, 2022 at 21:25
                Hello! Sorry about that I'm still knew to Power BI and Stackflow. Let me know If I added enough information or if there's anything I left out.
– Spen820
                Aug 7, 2022 at 20:20
        FILTER('Table', 
            EARLIER([Delivery Month]) = [Delivery Month] &&
            EARLIER([Charge Bucket]) = [Charge Bucket]))
Container per month = 
    CALCULATE(
        SUM([Number of containers]), 
        FILTER('Table', 
            EARLIER([Delivery Month]) = [Delivery Month] &&
            EARLIER([Charge Bucket]) = [Charge Bucket]))

Produces the same results you show in your table.

Note that the filter for the month works because all of the dates are on the same day of the month (1). If that was not the case, you'd have to add a column that shows year and month, and filter on that.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.