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

Sameperiod last year measure not working

Hi Experts

 

I am trying to work out the values for the same period last year, cannot see the wood for the trees as what i am doing wrong..

 

CALCULATE([TotalAssessments],SAMEPERIODLASTYEAR(DimDate[Month&Year])))

 

TotalAssessment = Measure 1 + Measure 2

1 ACCEPTED SOLUTION
v-yuezhe-msft
Employee
Employee

@Anonymous,

 

What result would you like to get? Could you please share sample data of your table and post expected result based on sample data here?

If you add the measure to Matrix and it doesn't return correct total value, please create a new measure using DAX below and drag the measure to your Matrix visual. The RowField is the field that you drag to Rows of Matrix visual.

SamePeriodLastYear= CALCULATE([TotalAssessments],FILTER(ALL(DimDate),DimDate[Year]=MAX(DimDate[Year])-1),SAMEPERIODLASTYEAR(DimDate[Date]))
NewMeasure = IF(COUNTROWS(VALUES(Table[RowField]))=1, [SamePeriodLastYear],SUMX(VALUES(Table[RowField]),[SamePeriodLastYear]))



Regards,
Lydia

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

4 REPLIES 4
v-yuezhe-msft
Employee
Employee

@Anonymous,

 

What result would you like to get? Could you please share sample data of your table and post expected result based on sample data here?

If you add the measure to Matrix and it doesn't return correct total value, please create a new measure using DAX below and drag the measure to your Matrix visual. The RowField is the field that you drag to Rows of Matrix visual.

SamePeriodLastYear= CALCULATE([TotalAssessments],FILTER(ALL(DimDate),DimDate[Year]=MAX(DimDate[Year])-1),SAMEPERIODLASTYEAR(DimDate[Date]))
NewMeasure = IF(COUNTROWS(VALUES(Table[RowField]))=1, [SamePeriodLastYear],SUMX(VALUES(Table[RowField]),[SamePeriodLastYear]))



Regards,
Lydia

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

Capture.PNG

 

Hi lydia

 

the total should be the sum of the individual periods as shown above...i.e. 34+21+ etc....

Anonymous
Not applicable

forgot to mention that

 

totalassessment is made up of two measures...

 

1. Remote1Assessment = CALCULATE(COUNTROWS(Table),Table[Field1]="true") and 

2. Remote2Assessment = CALCULATE(COUNTROWS(Table),Table[Field2]="true")

 

 

Anonymous
Not applicable

I have re worked the formula to..

 

= CALCULATE([TotalAssessments],FILTER(ALL(DimDate),DimDate[Year]=MAX(DimDate[Year])-1),SAMEPERIODLASTYEAR(DimDate[Date]))

 

but the total is wrong...

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.