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

Sameperiodlastyear giving (Blank) counts while applying filter

Hi All,

 

I have created 2 measures -

1) YTD Counts - which shows activity counts for currect year (2022)

YTD Activity = TOTALYTD(COUNT('Activity Details'[Activity Id]),DATESYTD('Activity details'[Activity Submission Date and time]))

 

2) YTD Counts for Last Year - which shoes activity counts for last year 

YTD Activity LY = CALCULATE([YTD Activity],SAMEPERIODLASTYEAR('Activity details'[Activity Submission Date and time]))
 
Now, I have some filters also in my dashboard throgh which I can do slicing and dicing of my KPIs. But, when I am appling any filter then Last year counts are returning (Blank) counts.

And due to this, my another measure is giving Infinity counts on Card KPI.
YTD Activity Incr. = ([YTD Activity]-[YTD Activity LY])/[YTD Activity LY]
 
Kindly help me to resolve issue that if I select any value from filter then last year counts should be filtered as per filter, which is giving (Blank) result.
 
Thanks!!!
1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a mesure to calculate count.

Count = 
IF (
    MONTH ( MAX ( [Activity Submission Date and time] ) ) = MONTH ( TODAY () ),
    CALCULATE (
        COUNT ( [Activity Id] ),
        FILTER (
            'Activity details',
            [Activity Submission Date and time]
                <= DATE ( YEAR ( [Activity Submission Date and time] ), MONTH ( TODAY () ), DAY ( TODAY () ) ))),
    COUNT ( [Activity Id] ))

and Percentage as follows:

Percentage = 
var _last= SUMX(FILTER(ALL('Activity details'),EOMONTH([Activity Submission Date and time],0)=EOMONTH(MAX([Activity Submission Date and time]),-12)),[Count])
return DIVIDE([Count]-_last,[Count])

The final output is shown below:

vyalanwumsft_0-1645173323912.png
Best Regards,
Community Support Team_ Yalan Wu
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

5 REPLIES 5
v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

You could create a mesure to calculate count.

Count = 
IF (
    MONTH ( MAX ( [Activity Submission Date and time] ) ) = MONTH ( TODAY () ),
    CALCULATE (
        COUNT ( [Activity Id] ),
        FILTER (
            'Activity details',
            [Activity Submission Date and time]
                <= DATE ( YEAR ( [Activity Submission Date and time] ), MONTH ( TODAY () ), DAY ( TODAY () ) ))),
    COUNT ( [Activity Id] ))

and Percentage as follows:

Percentage = 
var _last= SUMX(FILTER(ALL('Activity details'),EOMONTH([Activity Submission Date and time],0)=EOMONTH(MAX([Activity Submission Date and time]),-12)),[Count])
return DIVIDE([Count]-_last,[Count])

The final output is shown below:

vyalanwumsft_0-1645173323912.png
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks @v-yalanwu-msft , It solved my issue. 🙂

v-yalanwu-msft
Community Support
Community Support

Hi, @Anonymous ;

Can you post sample data as text and expected output?
Not enough information to go on;

 

Best Regards,
Community Support Team_ Yalan Wu

lbendlin
Super User
Super User

SAMEPERIODLASTYEAR() does not give you what you think it does. You need to add the YTD restriction yourself, otherwise it will return full periods.

 

Please provide sanitized sample data that fully covers your issue. If you paste the data into a table in your post or use one of the file services it will be easier to work with. Please show the expected outcome.

 

Anonymous
Not applicable

Dear @v-yalanwu-msft  @lbendlin 

My Apology for replying so late as was travelling.

 

sameperiodlastyear is giving entire feb month counts but that should calculate till 18th Feb only (as of today's date) and due to this my % Increament calculation is getting wrong.

 

Desired Result is in green color below

bhuprakash_0-1645165178922.png

 

Attaching data with you. Please download from below link.

https://we.tl/t-jTkta5Kinb

 

Thanks a lot in advance. 

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.