cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper IV
Helper IV

IF with conditions

Hi Experts, Help me out with this formula . I have two tables;
table[company],table[Sales],         table2[branch]…..
If company selected is A , return sales amount otherwise return sales amount for all other company BUT apply filter branch<> z
 
new column= IF(selectedvalue[company])=''A', SUM(table[Sale]) , CALCUALTE(SUM(table[Sale], NOT(CONTAINSTRINGS(table2[branch]),"z" )))
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Microsoft
Microsoft

Re: IF with conditions

Hi @schoden ,

 

We can create a new slicer based on a new distinct company table to meet your requirement.

 

1. Create a new table based on company.

 

distinct company = DISTINCT('Table'[company])

 

IF 1.jpg

 

2. Then we can create a slicer based on the company.

 

IF 2.jpg

 

3. At last we create a measure, and the result like this,

 

Measure = IF(SELECTEDVALUE('distinct company'[company])="A", SUM('Table'[Sales]) , CALCULATE(SUM('Table'[Sales]), NOT(CONTAINSSTRING('Table (2)'[branch],"z"))))

 

IF 3.jpg

 

IF 4.jpg

 

There is no relationship between Table and distinct table.

 

If it doesn’t meet you requirement, could you please show the exact expected result based on the table that we have shared?

BTW, pbix as attached.       

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Super User IV
Super User IV

Re: IF with conditions

@schoden , You have to create a new measure

new Measure= IF(selectedvalue[company]="A", SUM(table[Sale]) , CALCUALTE(SUM(table[Sale]), NOT(CONTAINSTRINGS(table2[branch],"z" ))))

 

Similar example

https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/50...



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Helper IV
Helper IV

Re: IF with conditions

@amitchandak  Hi thanks for the reply.

 

Yes it is measure I applied,  sorry I wrote as column.  

It is not filtering ...do you have better DAX for it.   ? 

Highlighted
Microsoft
Microsoft

Re: IF with conditions

Hi @schoden ,

 

We can create a new slicer based on a new distinct company table to meet your requirement.

 

1. Create a new table based on company.

 

distinct company = DISTINCT('Table'[company])

 

IF 1.jpg

 

2. Then we can create a slicer based on the company.

 

IF 2.jpg

 

3. At last we create a measure, and the result like this,

 

Measure = IF(SELECTEDVALUE('distinct company'[company])="A", SUM('Table'[Sales]) , CALCULATE(SUM('Table'[Sales]), NOT(CONTAINSSTRING('Table (2)'[branch],"z"))))

 

IF 3.jpg

 

IF 4.jpg

 

There is no relationship between Table and distinct table.

 

If it doesn’t meet you requirement, could you please show the exact expected result based on the table that we have shared?

BTW, pbix as attached.       

 

Best regards,

 

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Helper IV
Helper IV

Re: IF with conditions

@v-zhenbw-msft 

Thank you.

 

This is exactly my requirement.  

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors