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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
coliveira77
Frequent Visitor

The Date table does not relate to another date table

Hello friends from Power Bi,

For a week now I have been researching how to include a new table of interest rates and access according to the period of each line.

Link to the PBIX files 

coliveira77_0-1625693301264.png

 

 

1 ACCEPTED SOLUTION

Hello Friend @DataInsights thanks for the help, I was able with this formala see the value of the adjustment, then I make another measurement for the final value.

 

1 Valor Reajuste =
CALCULATE (
LASTNONBLANKVALUE (fReajustes[adjustment date] , [sum_reajustes]),
FILTER (
ALL ( dCalendar[Date]),
dCalendar[Date] <= MAX ( dbo[measure_date]
)
))

View solution in original post

6 REPLIES 6
DataInsights
Super User
Super User

@coliveira77,

 

Do you want a measure or calculated column? Here's the DAX for a measure, with the assumption that if no row exists in fReajustes for a Contract/Date, return the original amount.

 

Adjusted Amount = 
VAR vAmount =
    SUM ( dbo[item_valor_new] )
VAR vContract =
    MAX ( Contracts[Contracts] )
VAR vDate =
    MAX ( dCalendar[Date] )
VAR vRate =
    LOOKUPVALUE (
        fReajustes[adjustment percetual],
        fReajustes[Contracts], vContract,
        fReajustes[adjustment date], vDate
    )
VAR vResult =
    IF ( ISBLANK ( vRate ), vAmount, vAmount * vRate )
RETURN
    vResult

 

DataInsights_0-1626023819656.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hello, @DataInsights Thank you for your help, sorry for the delay, I was trying to solve it with your help.

 

I made a test and still didn't get the expected result, so I made an example of the result I want.

A column calculated according to the "Fat_new" lines of the "dbo" table, multiply with the lines of the "percentage adustment" column
table "fRreaadjustment", respecting the posting dates, not having corresponding value in the rows of the column "percentage adustment" of the table "fReajustes", return the same value of the rows "Fat_new" of the table "dbo".

Apresentação1.jpg

 

@coliveira77,

 

Try this measure:

 

Adjusted Amount = 
VAR vAmount =
    SUM ( dbo[Fat_new] )
VAR vContract =
    MAX ( Contracts[Contracts] )
VAR vDate =
    MAX ( dCalendar[Date] )
VAR vMaxRateDate =
    CALCULATE (
        MAX ( fReajustes[adjustment date] ),
        ALL ( fReajustes ),
        fReajustes[adjustment date] <= vDate,
        fReajustes[Contracts] = vContract
    )
VAR vRate =
    LOOKUPVALUE (
        fReajustes[adjustment percetual],
        fReajustes[Contracts], vContract,
        fReajustes[adjustment date], vMaxRateDate
    )
VAR vResult =
    IF ( ISBLANK ( vRate ), vAmount, vAmount * vRate )
RETURN
    vResult

 

DataInsights_0-1626732847020.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks for the help @DataInsights, but when I apply it to my file, it comes up with another value, I did some variations without success.

Capturar.JPG

 

@coliveira77,

 

Try breaking it down so you can see each component of the calculation. After RETURN in the measure, put vRate instead of vResult. This will display the rate being used. Do the same with each variable to identify the problem.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hello Friend @DataInsights thanks for the help, I was able with this formala see the value of the adjustment, then I make another measurement for the final value.

 

1 Valor Reajuste =
CALCULATE (
LASTNONBLANKVALUE (fReajustes[adjustment date] , [sum_reajustes]),
FILTER (
ALL ( dCalendar[Date]),
dCalendar[Date] <= MAX ( dbo[measure_date]
)
))

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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