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
Anonymous
Not applicable

Based on year selection last year value show

Hi all,

 

i have 3 years data,  if i select 2020 ,  2020 data and 2019 needed, 

if i select 2019 , 2019 data and 2018 data needed

 

based on year selection last year data needed

 

sample data 

 

YearValueBusiness
201973,431.49Allocated
201921,088.96Consumer
201911,203.00Consumer
201958.07Expenses
202013,234.34Expenses
202075,690.32Allocated
202017,817.28Consumer
202046.46Expenses
201871,822.32Allocated
201818,293.38Consumer
201869,064.75Expenses

 

 

i need result like this

 

business CY ValuePY  Value
Allocated71,822.3273,431.49
Consumer17,817.2832,291.96
Expenses69,111.2113292.21

 

Many thanks

Rajesh

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

Based on your description, you can create these two measures:

CY Value = SUM ( 'Table'[Value] )
PY Value = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Year]
            = SELECTEDVALUE ( 'Table'[Year] ) - 1
            && 'Table'[Business] IN DISTINCT ( 'Table'[Business] )
    )
)

Value.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

3 REPLIES 3
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

Based on your description, you can create these two measures:

CY Value = SUM ( 'Table'[Value] )
PY Value = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER (
        ALL ( 'Table' ),
        'Table'[Year]
            = SELECTEDVALUE ( 'Table'[Year] ) - 1
            && 'Table'[Business] IN DISTINCT ( 'Table'[Business] )
    )
)

Value.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@Anonymous , Create a separate year(Date) Table

 

This Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])))
Last Year = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]=max('Date'[Year])-1))
rolling 2 = CALCULATE(sum('order'[Qty]),filter(ALL('Date'),'Date'[Year]>=max('Date'[Year])-2 && 'Date'[Year]<=max('Date'[Year])) )

Anonymous
Not applicable

@amitchandak   thanks for your response

 

you mean create the date table then create the measure on sales table ?

 

 

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.