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
RevOps608
Helper I
Helper I

SAMEPERIODLASTYEAR() not working when categories are added to matrix

Hello,

 

I'm comparing Opportunities created MTD compared to same period last year. So August 23' to Aug 22'. My formula "MTD Opps" and MTD Opps (PY) both work when using dates as rows. But when I use categories(service lines), it breaks. On the second screen shot you'll see MTD OPPS filtered by Service Line. It's when I add MTD OPPS (PY) that it goes white and breaks. CreatedDate2__c and the opportunities being counted are located in the same table.

 

MTD Opps =
CALCULATE(
    COUNTROWS(Opportunity),
            DATESMTD(Opportunity[CreatedDate2__c]))
MTD Opps (PY) =
CALCULATE(
   [MTD Opps],
            SAMEPERIODLASTYEAR(Opportunity[CreatedDate2__c]))
relationships.jpgPower Bi MTD Opps.jpg
5 REPLIES 5
RevOps608
Helper I
Helper I

Figure it out. It was the .[Date] ate the end of 

SAMEPERIODLASTYEAR(Opportunity[CreatedDate2__c].[Date])).
Power Bi makes me want to pull my hair out.
 
Thanks for all the help though! Much appreciated
 
ToddChitt
Super User
Super User

The chart on the right, the one that has Channel on the rows. does that have any knowledge of what MONTH you are talking about? If not it will fail.

Try this: Add a relative date slicer to the page




Did I answer your question? If so, mark my post as a solution. Also consider helping someone else in the forums!

Proud to be a Super User!





It's using CreatedDate2__c, which is part of the same table. So it should have no issue referencing, correct?

mickey64
Super User
Super User

How about measures below?

 

MTD Opps =
CALCULATE(
COUNTROWS(Opportunity),
DATESMTD(Calendar[Date]))

 

MTD Opps (PY) =
CALCULATE(
[MTD Opps],
SAMEPERIODLASTYEAR(Calendar[Date]))

Not what I expected.

I had to slightly alter your formula by adding USERELATIONSHIP. MTD Opps now gives me opps for 22' and MTD Opps (PY) doesnt work.

MTD Opps =
CALCULATE(
    COUNTROWS(Opportunity),
    USERELATIONSHIP('Calendar'[Date], Opportunity[CreatedDate2__c]),
            DATESMTD('Calendar'[Date]))
MTD Opps PY =
CALCULATE(
    [MTD Opps],
    USERELATIONSHIP('Calendar'[Date], Opportunity[CreatedDate2__c]),
    SAMEPERIODLASTYEAR('Calendar'[Date]])
    )))py broke.jpgoff a year.jpg

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.