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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
SEAM_98
Frequent Visitor

Problem getting data from one table to another table in the range between dates

 

I have problems to create a column as inputs coming from different tables. It does not pull data from the other tables. I would like to know if you have any way to solve this problem.

Here is some information from my tables so you can understand what I am trying to do with an example.

 

Table 1

SEAM_98_1-1703190190736.png

 

Table 2

SEAM_98_0-1703190180456.png

 

I have my fact table (Table2) with dates. I want the dates that are between those ranges, to return me the "MES_CUOTA".

For example: 10/24/23 (From table 2) is between 09/26/2023 and 10/25/2023 (From table1) and in another column it should be returning October_23. So for each date in table 2.

1 ACCEPTED SOLUTION

@SEAM_98 

I modifed the code with a different approach:

MES_CUOTA = 
VAR _data = 'FACT COTIZACIONES'[FECHA DE CONFIRMACION DE RECEPCION DE LA OC DEL CLIENTE]
VAR _result = 
MAXX(
    FILTER(
        'DIM MES',        
        _data >= 'DIM MES'[Fecha Inicio] &&
        _data <= 'DIM MES'[Fecha Fin] 
    ),
    'DIM MES'[MES_CUOTA]
)
RETURN  _result
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
SEAM_98
Frequent Visitor

Hi @Fowmy 

 

I have to give you my PBI file in order to find the problem. 
https://we.tl/t-4N5jk5tkEG 

I am attaching link to download. Only have  7 days.

 

Please I look forward to your promt reply.

 

@SEAM_98 

I modifed the code with a different approach:

MES_CUOTA = 
VAR _data = 'FACT COTIZACIONES'[FECHA DE CONFIRMACION DE RECEPCION DE LA OC DEL CLIENTE]
VAR _result = 
MAXX(
    FILTER(
        'DIM MES',        
        _data >= 'DIM MES'[Fecha Inicio] &&
        _data <= 'DIM MES'[Fecha Fin] 
    ),
    'DIM MES'[MES_CUOTA]
)
RETURN  _result
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Fowmy
Super User
Super User

@SEAM_98 

Add a calculated column to your Table 2 using the following code:

MES_CUOTA_COL = 

    VAR __Data = table2[FECHA DE CONFIRMACION DE LA OC DELL CLIENTE]
    VAR __Result = 
        CALCULATE (
            MAX ( table1[MES_CUOTA ), 
            table1[Fecha Inicio] <= __Data, 
            table1[Fecha Fin] >=  __Data
        ) 
    RETURN
        __Result
            
Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

SEAM_98
Frequent Visitor

Hi @Fowmy  

I don't  know only works for the year 2023. The others previous years don't work :c. For example,

 

SEAM_98_1-1703261415403.png

But with 2023, it works.

SEAM_98_2-1703261504259.png

I tried moving the data (only the dates from my table, Mes cuota) in another spreadsheet and it worked. I understand the my table  has some issues.

 I check and those fields are with the correct format.

I don't know how can I fix it.

This is my table from mes_cuota

 

SEAM_98_3-1703261794880.png

 

Please your help. I moved sensitive information in order to give you, but when I run the code It worked. I don't know why.

@SEAM_98 

Please check your data, the code should work any date as long as there is data. Please share a dummy PBI file to check 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 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.