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

If then statement returns all values

Attempting to use an if, then statement so that IF a column has a certain value then calcuated result will either return a "%" or text value that indicates "No number"

eg. If(sum(uplift cases)<1, "No Uplift", Divide( uplift cases,base cases,0))

The Dax measure returns the expected value if uplift is less than one the table column reads "No Uplift" and is uplift is 1 or higher it returns the % calculation from the Divide function.

ISSUE: when I filter customer (Using slicer) for a specific account the table returns ALL customers and not just slicer selection. I've tried wrapping in Calculate ALL SELECTED, SELECTED VALUE and also using VAR's.  All patterns return expected result but all variations still return all Customers vs. just selected.  Always appreciate the assistance.

1 ACCEPTED SOLUTION

Thanks for reviewing post... I think I found a solution.  I put the If/then as a calculated column and then used that column in my table.

Now when customer is selected in slicer it only shows that customers.

 

Thanks, Spencer_II

View solution in original post

6 REPLIES 6
Community Champion
Community Champion

@spencer_II 

What is the relationship defined in the model?

Does your measure return Text and % ??. 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Thanks for responding///

Yes measure will return both Text and % value.  The issue is when I filter the customer ALL customers show in table vs. just selected.

Customer from data table has a many to 1 relationship with Customers table and is SINGLE on cross filter direction.

 

 

Community Champion
Community Champion

@spencer_II 

Not clear enough, 

Can you share a sample PBIX file show me the expected behavior?

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

Case % Lift = If(sum(Tbl_BPPromoSumry[Uplift - With (m1052)])<1,"No Uplift",
DIVIDE(sum(Tbl_BPPromoSumry[Uplift - With (m1052)]),sum(Tbl_BPPromoSumry[Base Shipments (m4120)]),0))

 

Expected result:

spencer_II_0-1604237426017.png

Returned result:

 

spencer_II_3-1604237522114.png

 

Thanks for reviewing post... I think I found a solution.  I put the If/then as a calculated column and then used that column in my table.

Now when customer is selected in slicer it only shows that customers.

 

Thanks, Spencer_II

View solution in original post

Hi @spencer_II ,

Glad to hear the issue is solved. You can accept your reply as solution, that way, other community members could easily find the answer when they get same issues.

Best Regards,
Community Support Team _ Yingjie Li

Helpful resources

Announcements
secondImage

Happy New Year from Power BI

This is a must watch for a message from Power BI!

December Update

Check it Out!

Click here to read more about the December 2020 Updates!

Community Blog

Check it Out!

Click here to read the latest blog and learn more about contributing to the Power BI blog!

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Top Solution Authors
Top Kudoed Authors