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
rickylee
Helper III
Helper III

How to compare current and previous year's result from two different table and list as bar chart?

Hello,

I have two tables with different columns. I try to list the total price in table 1 (total price 2018) and the total price from table 2(total price 2017) in a bar chart. So people can look at current year's total price and the previous year. I only need to compare monthly i.e. 2018 Jan compares to 2017Jan. I mange to learn "SAMEPERIODLASTYEAR" but no joys because I have two tables rather than one.

Unfortunately, I cannot attach pbix file  but both tasble can be see here:

DateAssessment PriceAssessorModification date
01/01/2018A10  
11/01/2018B10  
21/01/2018C10  
01/02/2018A20  
11/02/2018B20  
21/02/2018C20  

 

DateAssessmentPrice
01/01/2017E100
11/01/2017F100
21/01/2017G100


I tried to put both price in the both tables together. Somehow, the total price in 2017 appears when the date is 2018. 

 

question.png

 

Could someone help? "SAMEPERIODLASTYEAR" won't work becasue I have two tables. By the way, is there a way to attach file / picture?

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @rickylee,

 

We need a Date table in your scenario. Then these two tables will be connected through the date table. Either of the two measure below will be OK.

Calendar = CALENDARAUTO()
Measure =
CALCULATE ( SUM ( Table2[Price] ), SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) )
Measure =
CALCULATE (
    SUM ( Table1[Price] ) + SUM ( Table2[Price] ),
    SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
)

How_to_compare_current_and_previous_year_s_result

 

Best Regards,

Dale

Community Support Team _ Dale
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

2 REPLIES 2
v-jiascu-msft
Employee
Employee

Hi @rickylee,

 

We need a Date table in your scenario. Then these two tables will be connected through the date table. Either of the two measure below will be OK.

Calendar = CALENDARAUTO()
Measure =
CALCULATE ( SUM ( Table2[Price] ), SAMEPERIODLASTYEAR ( 'Calendar'[Date] ) )
Measure =
CALCULATE (
    SUM ( Table1[Price] ) + SUM ( Table2[Price] ),
    SAMEPERIODLASTYEAR ( 'Calendar'[Date] )
)

How_to_compare_current_and_previous_year_s_result

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

It works perfectly!

Thank you.

Kind regards,
Ricky

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.