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
RobX
Advocate I
Advocate I

If Statement With Two Tables

I have two tables with a one to many relationship.  I'm trying to create a measure display true/false if the summed value in one table is greater than the summed value in the other table.

 

I tried this measure but it's duplicating my records.  Does anyone know how to correct this?

 

TrueFalse=
IF(SUM(TableA[Amount]) < SUM(TableB[Amount]), "True", "False")
3 REPLIES 3
edhans
Super User
Super User

Amount A shoud not be an implict measure. So make Amount A be a measure like
Total Amount A = SUM(Table[Amount A])

Same for Amount B.

Then use 

IF([Total for Amount A] < [Total for Amount B], "True", "False")

as your measure. That is really the same as wrapping your SUM()s above with a CALCULATE.

 

If you want actual tested code, please provide data per the links below. I cannot copy your images in to Power BI. 

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
edhans
Super User
Super User

Very hard to understand the requirements without sample data and expected results, and there is no indication of what the evaulation context is here. Sample data would be great. Without that, the only thing I can suggest is wrap both SUM() functions with CALCULATE() and see if the context transition gets you what you need. If not, provide data please and expected results.

 

How to get good help fast. Help us help you.
How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Here's a sample.

 

TableA

RobX_4-1607711181590.png

 

 

TableB

RobX_3-1607711164952.png

 

 

I want to create the table below with the measure "A Less Than B"

RobX_2-1607711112807.png

 

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.

Top Solution Authors