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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Adams_Apple
Frequent Visitor

IF statement calculating both values

I am trying to use an IF statement to use values from two different tables. The first table contains actual production data and the second contains projections for future numbers. This is used in a matrix to display actual data for the past and current month and then projection data for future months in the year.

It seems to be using values from both tables in months where data exists in both tables during the same month. 

 

Projected_BinsPacked =
CALCULATE(
SUMX(
    VALUES('Date'[Date].[Month]),
    IF(SUM('Bins'[Bins Packed]) > 0,
        SUM('Bins'[Bins Packed]),
        MAX(Projections[Bins Packed])
        )
    ))
 
thank you
1 ACCEPTED SOLUTION

Hi @Adams_Apple 

 

Th's good to hear the measure is working for you! In order to works sum of total correct, you may use SUMX function to iterate over the table and calculate total sum correctly. Give a try with the below measure.

 

Projected_BinsPacked =
SUMX(
    VALUES('Date'[Date].[Month]),
    CALCULATE(
        COALESCE(SUM('Bins'[Bins Packed]), MAX(Projections[Bins Packed])))
)

 

Let me know if it works.

 

Thank you!

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @Adams_Apple ,

You can create another new measure as below and put it on Values fields of matrix to replace the measure [Projected_BinsPacked]:

Measure = SUMX ( VALUES ( 'Date'[Date].[Month] ), [Projected_BinsPacked] )

If the above one can't help you figure out, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic base on the provided sample data. It would be helpful to find out the solution. You can refer the following link to share the required info:

How to provide sample data in the Power BI Forum

 

And it is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

How to upload PBI in Community

Best Regards

suparnababu8
Super User
Super User

Hi @Adams_Apple 

 

It seems like  your current approach likely uses an IF statement that checks for the existence of actual data. If actual data exists, the measure should use it. Otherwise, it should use projected data.  you can try with COLEASE dax function in place of IF. Let's give a try with below measure

Projected_BinsPacked =
CALCULATE(
    SUMX(
        VALUES('Date'[Date].[Month]),
        COALESCE(SUM('Bins'[Bins Packed]), MAX(Projections[Bins Packed])))
)

 

Let me know if it works.

 

Thanks

that works great, thank you. however, the sum total isn't correct. how can i modify that measure so it has the correct sum total?

Adams_Apple_0-1736898146211.png

 

Hi @Adams_Apple 

 

Th's good to hear the measure is working for you! In order to works sum of total correct, you may use SUMX function to iterate over the table and calculate total sum correctly. Give a try with the below measure.

 

Projected_BinsPacked =
SUMX(
    VALUES('Date'[Date].[Month]),
    CALCULATE(
        COALESCE(SUM('Bins'[Bins Packed]), MAX(Projections[Bins Packed])))
)

 

Let me know if it works.

 

Thank you!

Thank you so much, works perfectly!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.