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
ChristianDGreat
Resolver I
Resolver I

Get last year last entry

I got stuck into this, hopefully, someone can help me with this
So I have this Custom Calendar Table

SeasonWeekendingProductSub Product
202110/29/2022AA-1
202111/5/2022AA-1
202211/12/2022AA-1
202211/19/2022AA-1
20218/27/2022AA-2
20219/3/2022AA-2
20229/10/2022AA-2
20229/17/2022AA-2
20229/24/2022AA-2


and transacation table :

SeasonWeekendingProductSub ProductQty
20219/3/2022AA-2111
202110/29/2022AA-1222
202211/5/2022AA-233
202211/12/2022AA-244
202211/19/2022AA-155



The result Im looking for is something like this

Filter :
Season = 2022,
Product = A,
Sub Product = All

ProductSub ProductQty
AA-10
AA-2111
Total 111

 

Explanation :


Basically what this does is if a user select Season = 2022, it need to scan the Custom Calendar on the MIN date available for 
Product, Season and Sub Product combination, in this case in row 1, its 11/12/2022, then we need to subtract 7 there
so the date will be 11/5/2022. Now we need to look at the transaction table if we have those match for the 2021 Season.
In this case theres none so its 0

For Row 2 result, the minimum date for the Custom Calendar is 9/10/2022, minus 7 thats 9/3/2022,
When we lookup the transaction table for 9/3/2022 and 2021 we get 111

 

Hope this makes sense.

*basically we are looking at the last weekending of the previous year.

 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1676953390803.png

 

 

Expected result measure: =
VAR _mindateandoneweekbefore =
    MIN ( 'Calendar'[Weekending] ) - 7
RETURN
    SUMX (
        FILTER (
            'Transaction',
            'Transaction'[Weekending] = _mindateandoneweekbefore
                && 'Transaction'[Product] = MAX ( 'Calendar'[Product] )
                && 'Transaction'[Sub Product] = MAX ( 'Calendar'[Sub Product] )
        ),
        'Transaction'[Qty]
    ) + 0

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

1 REPLY 1
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1676953390803.png

 

 

Expected result measure: =
VAR _mindateandoneweekbefore =
    MIN ( 'Calendar'[Weekending] ) - 7
RETURN
    SUMX (
        FILTER (
            'Transaction',
            'Transaction'[Weekending] = _mindateandoneweekbefore
                && 'Transaction'[Product] = MAX ( 'Calendar'[Product] )
                && 'Transaction'[Sub Product] = MAX ( 'Calendar'[Sub Product] )
        ),
        'Transaction'[Qty]
    ) + 0

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


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.