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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

CALCULATE values from two tables, ignore data from Table A when Table B has value

Good day,

 

I have two tables. Table B is a SQL database, and Table A is a table where the user can insert manual data. 

The idea is that once in while the data in the SQL table is wrong, then user can insert the summarized value for a whole month. 

(Tables have several tag numbers)

 

Table A

DateTagvalue
31-01-20231

5000

31-01-202326000
28-02-202321000
   

 

Table B

DateTagValue
02-01-2023120
03-01-2023130
04-01-2023115
05-01-2023140
-1-
-1-
-1-
-1-
31-01-2023125

 

What I want, is to "ignore" values in Table B whenever Table A has a manual input.

 

I managed with assistance, to use below measure:

 

PM Consumption = 
SUMX (
    VALUES ( dim_date[Date]),
    COALESCE (
        CALCULATE (SUM ( Table A[Value])) ,
        CALCULATE ( MAX(Table B[Value]) - MIN( Table B[Value]) )

 

 

But this measure only replace the value on the 31-01-2023. I want the measure to "ignore" all data from Table B during january 2023, since there is a manual input in Table A. And only show the summarized value from Table A.

 

Thanks in advance.

 

 

 

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , for that you need have common dimension like date

 

and then you can have measure like

 

Sumx(Values(Date[Month Year]), calculate(if(not(Isblank(sum(TableA[Value]))) , sum(TableA[Value]), sum(TableB[Value]))))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Thank you for your reply @amitchandak 🙂

 

First of all sorry I forgot to mention that I do have a date table. 

 

Your solution partly works. I try to explain in below picture.

 

I still see data logged from table B when I have data in table A. But the Total is correct. 

 

Hope this makes sense. 

 

PowerBI.JPG

 

TABLE A = 
SUM ( Fact_PrevEnergyDataAP[Value] ) / 1000
TABLE B = 
( MAX ( Fact_EnergyData[Value] ) - MIN ( Fact_EnergyData[Value] ) ) / 1000
Consumption = 
SUMX (
    VALUES ( dim_date[Month] ),
    CALCULATE ( IF ( NOT ( ISBLANK ( [TABLE A] ) ), [TABLE A], [TABLE B] ) )
)

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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