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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
gwaczoka
Regular Visitor

New column with value from previous (last) date

Hi guys,

can someone please help me with this issue:

I would like to have in another column product flag from previous date (not DAY-1, but last previous) 

gwaczoka_1-1667393420348.png

 

I've found a solution for similar problem:

Previous Day Sales = 

CALCULATE(
    SUM(Table2[Sales]),
    LASTDATE(
    FILTER(
        ALL(Table2[Date] ),
        Table2[Date] < EARLIER([Date]) 
        )
    ), 
    ALLEXCEPT(Table2,Table2[Store ID])
)

 

 

but I have two variables: ID and vendor

 

Can you please help me to achieve a solution like in Column E?

 

DateIDVendorProduct flag
19.09.20221A1
19.09.20221B0
19.09.20221C0
20.09.20222A0
20.09.20222B1
20.09.20222C1
21.09.20223A1
21.09.20223B1
21.09.20223C1
22.09.20224A1
22.09.20224B0
22.09.20224C1
5 REPLIES 5
gwaczoka
Regular Visitor

Hey, can anyone please help? 😞 

Greg_Deckler
Community Champion
Community Champion

@gwaczoka Try:

Column = 
    VAR __Date = [Date]
    VAR __Vendor = [Vendor]
    VAR __Last = MAXX(FILTER('Table2',[Date] < __Date && [Vendor] = __Vendor),[Date])
    VAR __Result = MAXX(FILTER('Table2',[Date] = __Last && [Vendor] = __Vendor),[Product flag])
RETURN
    __Result


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg,

thank you for the response and  sorry for late reply.

It doesn't work, because there is no information about ID of the product included 😞
It is in the second column, might looks like hidden

Anonymous
Not applicable

Hi @gwaczoka,

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Hi,

can it like this? Maybe it's not a pbix, but it should help.
In the last column you can find excepted result, notice that I deleted vendor C for ID 3, so previous flag for day 22.09 is getting the data not from 21, but from 20.09

 

looking quickly at the table, it is easy not to notice that there is a column B with ID, but it's important

 

DateIDVendorProduct flagPrevious flag
19.09.20221A1 
19.09.20221B0 
19.09.20221C1 
20.09.20222A01
20.09.20222B10
20.09.20222C01
21.09.20223A10
21.09.20223B11
22.09.20224A11
22.09.20224B01
22.09.20224C10

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors