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
TagMan
Regular Visitor

how do you calculate an accumulated total of the prior years count of record IDs

This seems like it should be easy - but, I am a super newb to power bi. I was able to figure out accumulated total sales for the prior year period (filtered by page filter and slicer) but, when I try to use the same logic counting records (filtered by page filter and slicer), I get nowhere. This measure returns data I need for prior year, but it's not accumulated: 

 

RecordID PY =
Calculate(COUNT(Opportunity[RecordID]), SAMEPERIODLASTYEAR('Calendar Master From Sharepoint Raw Datasets'[Date].[Date]))

When I try to sum them up like this: 

RecordID PY Accumulated =
CALCULATE([RecordID PY],(FILTER(ALLSELECTED('Calendar Master From Sharepoint Raw Datasets'), 'Calendar Master From Sharepoint Raw Datasets'[Date] <= MAX('Calendar Master From Sharepoint Raw Datasets'[Date]))))

 

I get nothing... any suggestions from the gurus?? I'd really appreciate the help!

 

 

 

1 ACCEPTED SOLUTION
liuqi_pbi
Resolver II
Resolver II

Hi @TagMan 

 

If you have a Year column in the Date table, you can try this measure

Cumulative Count PY =
VAR _year = MAX ( 'Date'[Year] ) - 1
VAR _maxDate = EDATE ( MAX ( 'Date'[Date] ), -12 )
RETURN
    CALCULATE (
        COUNT ( Opportunity[RecordID] ),
        ALL ( 'Date'[Date] ),
        'Date'[Year] = _year,
        'Date'[Date] <= _maxDate
    )

 

EDATE function (DAX) - DAX | Microsoft Docs

 

----------------------------------------------------------------------

If this reply helps solve the problem, please mark it as Solution! Kudos are appreciated too!

View solution in original post

4 REPLIES 4
liuqi_pbi
Resolver II
Resolver II

Hi @TagMan 

 

If you have a Year column in the Date table, you can try this measure

Cumulative Count PY =
VAR _year = MAX ( 'Date'[Year] ) - 1
VAR _maxDate = EDATE ( MAX ( 'Date'[Date] ), -12 )
RETURN
    CALCULATE (
        COUNT ( Opportunity[RecordID] ),
        ALL ( 'Date'[Date] ),
        'Date'[Year] = _year,
        'Date'[Date] <= _maxDate
    )

 

EDATE function (DAX) - DAX | Microsoft Docs

 

----------------------------------------------------------------------

If this reply helps solve the problem, please mark it as Solution! Kudos are appreciated too!

ronaldbalza2023
Continued Contributor
Continued Contributor

Hi @TagMan , try this:

 

RecordID PY Accumulated =
CALCULATE (
    [RecordID PY],
    (
        FILTER (
            ALL ( 'Calendar Master From Sharepoint Raw Datasets' ),
            'Calendar Master From Sharepoint Raw Datasets'[YourYearSlicer]
                = MAX ( 'Calendar Master From Sharepoint Raw Datasets'[YourYearSlicer] )
                && 'Calendar Master From Sharepoint Raw Datasets'[Date]
                    <= MAX ( 'Calendar Master From Sharepoint Raw Datasets'[Date] )
        )
    )
)

 

Your way smarter than me...I don't know what value [youryearslicer] is.. I've tried [Date]... but end up with no data still...I appreciate your help!

[YourYearSlicer] means your Year filter (if you have one I assume). Check your dataset otherwise kindly provide your pbix file here removing the critical info 🙂
Cheers xx

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.