cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NickProp28
Post Partisan
Post Partisan

LOOKUPVALUE

Dear Community, 

 

As I have two tables, DB and ActualProfit, I would like to look up the sum of DB table based on month and year into ActualProfit table, but Do not replace the numbers in Actual Profit that are already filled up.

 

NickProp28_0-1653368655779.png

This is Actual Profit table.

 

NickProp28_1-1653368684346.png

This is DB table.

 

I would like to sum the value of months February and March in the DB table then look into the Actual Profit table.
Knowing that this code can look up the total profit, but will replace the actual profit that has been filled

lookup = CALCULATE(SUM('DB'[Profit]),FILTER('DB','DB'[Month]= ActualProfit[Month] && 'DB'[Year] = ActualProfit[Year] ))

NickProp28_3-1653369558278.png

 

Expectation: 

NickProp28_2-1653369269995.png

Any help will be greatly appreciated.

Attached with the pbix: https://drive.google.com/file/d/1x-snBm9WxQl8esw8Mz1AB4JekGj41Za5/view?usp=sharing

 

1 ACCEPTED SOLUTION
PC2790
Super User
Super User

Hey @NickProp28 ,

 

You can try something like this:

lookup = if(ActualProfit[Profit]<> BLANK(),ActualProfit[Profit],CALCULATE(SUM('DB'[Profit]),FILTER('DB','DB'[Month]= ActualProfit[Month] && 'DB'[Year] = ActualProfit[Year] )))

This will create a new column taking values from the Profit if they are already there and if not, it will do the calculation and fill the result. The outcome will be as:

PC2790_0-1653371610184.png

Will this solve the purpose?

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please check the below picture and the attached pbix file.

It is for creating a new column.

 

Untitled.png

 

lookup =
VAR _condition =
    ISBLANK ( ActualProfit[Profit] )
RETURN
    CALCULATE (
        SUM ( 'DB'[Profit] ),
        FILTER (
            'DB',
            'DB'[Month] = ActualProfit[Month]
                && 'DB'[Year] = ActualProfit[Year]
        )
    ) * _condition + ActualProfit[Profit]

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


PC2790
Super User
Super User

Hey @NickProp28 ,

 

You can try something like this:

lookup = if(ActualProfit[Profit]<> BLANK(),ActualProfit[Profit],CALCULATE(SUM('DB'[Profit]),FILTER('DB','DB'[Month]= ActualProfit[Month] && 'DB'[Year] = ActualProfit[Year] )))

This will create a new column taking values from the Profit if they are already there and if not, it will do the calculation and fill the result. The outcome will be as:

PC2790_0-1653371610184.png

Will this solve the purpose?

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

Power BI Dev Camp Session 25 with aka link 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, August 25 at 11a PDT for a great session with Ted Pattison!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors