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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cristianj
Helper IV
Helper IV

Hello. i am tryng to get previously valid data

cristianj_0-1660645403101.png

 

Hello, i am trying to get the exchange rate from official site, but they have data only for working day, so i try to make this column in which if i don,t have a valid date , to get the previously valid date

this is the formula

EurZT = if(ISBLANK('Curs Valutar Zilnic'[Eur])
            ,calculate(LASTNONBLANK('Curs Valutar Zilnic'[Eur],1),filter(all('Curs Valutar Zilnic'),('Curs Valutar Zilnic'[Eur])>0&&'Curs Valutar Zilnic'[DateYearNumber]<[DateYearNumber]))
            ,('Curs Valutar Zilnic'[Eur])
        )
the problem is the the data isblank.
Thank you for your help.

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @cristianj 
Please try

EurZT =
VAR CurrentEUR = 'Curs Valutar Zilnic'[Eur]
VAR CurrentDate = 'Curs Valutar Zilnic'[Date]
VAR PreviousTable =
    FILTER ( 'Curs Valutar Zilnic', 'Curs Valutar Zilnic'[Date] < CurrentDate )
VAR NonBlankTable =
    FILTER ( PreviousTable, 'Curs Valutar Zilnic'[Eur] <> BLANK () )
VAR PreviousRecord =
    TOPN ( 1, NonBlankTable, 'Curs Valutar Zilnic'[Date] )
VAR PreviousEUR =
    MAXX ( PreviousRecord, 'Curs Valutar Zilnic'[Eur] )
RETURN
    COALESCE ( CurrentEUR, PreviousEUR )

View solution in original post

2 REPLIES 2
cristianj
Helper IV
Helper IV

Thank you

tamerj1
Super User
Super User

Hi @cristianj 
Please try

EurZT =
VAR CurrentEUR = 'Curs Valutar Zilnic'[Eur]
VAR CurrentDate = 'Curs Valutar Zilnic'[Date]
VAR PreviousTable =
    FILTER ( 'Curs Valutar Zilnic', 'Curs Valutar Zilnic'[Date] < CurrentDate )
VAR NonBlankTable =
    FILTER ( PreviousTable, 'Curs Valutar Zilnic'[Eur] <> BLANK () )
VAR PreviousRecord =
    TOPN ( 1, NonBlankTable, 'Curs Valutar Zilnic'[Date] )
VAR PreviousEUR =
    MAXX ( PreviousRecord, 'Curs Valutar Zilnic'[Eur] )
RETURN
    COALESCE ( CurrentEUR, PreviousEUR )

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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