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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
yfquirogah
Helper I
Helper I

Filter in data base

I have this issue:

 

I have 2 tables, the first one shows Positions that have been removed, the date this happened and a column that indicates a code that belongs to an specific area; the second table shows the area this code belongs to. The codes table may change monthly, that is why I need to create a colum that according to the date the position was released it looks in that interval of data to find the area the code belonged to at the time.

 

First table:

 

OM Position IDOM Position NameFecha de BajaMesMonthYearCe.coste
10705627GLOBAL BRANDS MANAGER15/01/2020Enero12020COPEC02203
10704392LOCAL PREMIUM BRANDS MANAGER11/01/2020Enero12020COBA002070
10765089PRODUCTION MANAGER13/01/2020Enero12020COPEC01613
10853367TRANSFORMATION DIRECTOR11/02/2020Febrero22020COPEC02203
10703825BREWING 128/02/2020Febrero22020COBA002070
10704734ZONE WATER & ENERGY15/02/2020Febrero22020COPEC01613
10705219LEGAL DIVISION30/03/2020Marzo32020COPEC02203
10704005BREWING TEAM 327/03/2020Marzo32020COBA002070
10846442PEOPLE EC DIRECTOR22/03/2020Marzo32020COPEC01613

 

 

Second table:

MonthYearCe.costeCentro de costeFunction
12020COPEC02203BRAND MANAGEMENTMarketing
12020COBA002070PREMIUM BRANDS MANAGEMENTMarketing
12020COPEC01613ENGINEER MANAGEMENTSupply
22020COPEC02203BRAND MANAGEMENTMarketing
22020COBA002070PREMIUM BRANDS MANAGEMENTSales
22020COPEC01613ENGINEER MANAGEMENTSupply
32020COPEC02203BRAND MANAGEMENTLegal & CA
32020COBA002070PREMIUM BRANDS MANAGEMENTSales
32020COPEC01613ENGINEER MANAGEMENTPeople

 

I tried to make the relationships but i keep receiving the same result that is basically a combination of the Position with each one of the code results for every month.

 

I have been looking around on how to resolve this, I found a post with a formula that goes this way:

 

Function =
CALCULATE (
    FIRSTNONBLANK ( Table2[Function], 1 ),
    FILTER (
        Table2,
        Table2[month] = Table1[month]
            && Table2[year] = Table1[year]
    )
)

I understand what the function is supposed to do, and I think in theory it should work but when I get to the filters I'm not able to access the information on table 1. 

 

I would really appreciate your help.

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @yfquirogah ,

 

Based on your description, you want to display "function" of Table 2 according to "month", "year" and "CE. Coste" in Table 1.

You can try to concatenate "month" "year" "CE. Coste" and create a relationship for the two tables.

Column = CONCATENATE('Table'[Year],CONCATENATE('Table'[Month],'Table'[Ce.coste]))

test_filter_in_data_base.PNGtest_filter_in_data_base2.PNG

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
V-lianl-msft
Community Support
Community Support

Hi @yfquirogah ,

 

Based on your description, you want to display "function" of Table 2 according to "month", "year" and "CE. Coste" in Table 1.

You can try to concatenate "month" "year" "CE. Coste" and create a relationship for the two tables.

Column = CONCATENATE('Table'[Year],CONCATENATE('Table'[Month],'Table'[Ce.coste]))

test_filter_in_data_base.PNGtest_filter_in_data_base2.PNG

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ashish_Mathur
Super User
Super User

Hi,

Does this calculated column formula work?

Function = CALCULATE(FIRSTNONBLANK(Table2[Function],1),FILTER(Table2,Table2[month]=EARLIER(Table1[month])&&Table2[year]=EARLIER(Table1[year])&&Table2[Ce.Coste]=EARLIER(Table1[Ce.Coste])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.