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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Chocnut
Regular Visitor

Sumif Funtion in Power BI Desktop

Hi,

 

I have a data table as below, there are "Vendor", "Team" and respective "Spend".

 

After I load this table into Power BI Desktop, I would like to see the Vendors which have both Spend in Team A and B in a new table, i was trying to use Calculate or Sumx but can not figure out a way to do it, can someone help me with this? Thanks a lot.

 

Original Data:

VendorTeamSpend
AX2000
BX3000
CY1000
AY2000
CZ2000
BY5000
BX2000

 

Data required:

VendorTeam A SpendTeam B Spend
A  
B  
1 ACCEPTED SOLUTION

Thanks @v-shex-msft.

 

I finally figured out an easier way to do it by using Summerize to generate the list of Vendors, then use Calculate to capture spend for other teams, and use ISBLANK to filter out the vendors have shared spend between 2 teams.

 

 

View solution in original post

13 REPLIES 13
v-shex-msft
Community Support
Community Support

HI @Chocnut,

 

You can use matrix visual to achieve your requirement.

Drag 'Vendor' to rows, 'Team' to column, 'Spend' to values field.

1.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thanks a lot @v-shex-msft, much appreciate your solution.

 

Is it possible to use DAX instead of using Matrix to create a table? Because I only want to see those vendors who incurred expenses for both Team X and Y, I do not want to see Team Z here.

 

 

Hi @Chocnut,

 

>>Because I only want to see those vendors who incurred expenses for both Team X and Y, I do not want to see Team Z here.

You can add a filter/slicer to filter on team to achieve this simply.

3.PNG

 

Use dax formula to create a summary table also suitable this, but I think formula will more complex than above.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft, thanks for the prompt response.

 

Although we can apply filter to remove Team Z here, however how to remove vendors do not have spend for both Team X and Y.

 

For Example, Team C should not appear in the Matrix here...

 

I'm not saying Matrix is not good, it's just not a perfect solution to my request...

 

I tried to use Summarize function however can not figure out how, do you have any idea? Thanks.

Hi @Chocnut,

 

>>For Example, Team C should not appear in the Matrix here...

Actually, it will disappear when you fully filter item exist in specific vendor.

For e.g. I only keep team x in filter, vendor c will disappear.

 

>>I tried to use Summarize function however can not figure out how, do you have any idea?

Normal summarize can't generate the reuslt, you need to write some other steps to generate detail team columns.

 

BTW,you can also try to use pivot column feature(query editor) to generate the detail table.

Sample:

1.gif

 

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft,

 

Much appreicate your help here, I just got a new skill from you 🙂

 

Maybe I didn't explain properly in my previous post, I need to only have Vendors who incurred BOTH spend with Team X and Y, for example, Vendor C doesn't incur spend with Team X, so should not include in the table.

 

The correct result should be shown as below:

 

VendorTeam X SpendTeam Y Spend
A 20002000
B 50005000

 

Thanks mate.

Hi @Chocnut,

 

>>Maybe I didn't explain properly in my previous post, I need to only have Vendors who incurred BOTH spend with Team X and Y, for example, Vendor C doesn't incur spend with Team X, so should not include in the table.

Normal slicer/filter can't achieve your requirement.
In my opinion, I'd like to suggest you write a measure as tag to filter on records.

 

Sample:

1. Create selector table.

Selector = VALUES(Sample[Team])

2. Write measure to compare current list and selected list.

Flag = 
var current_vendor=LASTNONBLANK('Sample'[Vendor],[Vendor])
var current_team=CALCULATETABLE(VALUES('Sample'[Team]),'Sample'[Vendor]=current_vendor)
var seleted_team=ALLSELECTED(Selector[Team])
var conditions=IF(COUNTROWS(seleted_team)<2,seleted_team in current_team,CONCATENATEX(INTERSECT(current_team,seleted_team),[Team],",")=CONCATENATEX(current_team,[Team],","))
return
IF(conditions,"Y","N")

3. Create matrix visual and drag flag measure to visual level filter, then switch filter mode to 'is', result Y. 

7.PNG

4. Create slicer based on selector table.

 

Result:

2.gif

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Hi @v-shex-msft,

 

Thanks for the solution provided.

 

I tried to write the measures however it seems i can not locate "VAR" as the DAX syntax, what shows there are "VAR.P", "VAR.S", "VARX.P" and "VARX.S", I'm not very familiar with VAR, is this something normal? Thanks

 

screenshot of VAR.jpg

HI @Chocnut,

 

Var function is used to define the variable, you not need to care about the auto-spell notice:

VAR (DAX)

 

Regards,

Xiaoxin Shengt

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thanks @v-shex-msft.

 

I finally figured out an easier way to do it by using Summerize to generate the list of Vendors, then use Calculate to capture spend for other teams, and use ISBLANK to filter out the vendors have shared spend between 2 teams.

 

 

 Hi,

 

I have a table as below and I would like to see the vendors which have both spend under Team X and Team Y in a new table (not via table or matrix), i tried to use Summarize but can not figure out how to do that, can someone help with it? Thanks a lot.

 

Original Data:

 

VendorTeamSpend
AX2000
BX3000
CY1000
AY2000
CZ2000
BY5000
BX2000

 

Data required:

VendorTeam X SpendTeam Y Spend
A  
B  

 

 

Hello guys, can someone pls assist me? Cat Sad

Hi there,

 

Could someone help me with this please? Thanks.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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