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
NilR
Post Patron
Post Patron

Summarize for SAMEPERIODLASTYEAR() not working

I am summing CY to SPLY Data ,  but data disapears!

 

 

 

NUM=
Var _Union=
GROUPBY(
UNION(
    SUMMARIZE('TBL',[GP],[ID],[DATE], "@CTCS",CALCULATE(SUMX('TBL',[MBR_CTCS]),SAMEPERIODLASTYEAR('Calendar'[Date]))),
    SUMMARIZE('TBL',[GP],[ID],[DATE], "@CTCS",CALCULATE(SUMX('TBL',[MBR_CTCS])))
),
[GP],[ID],[DATE], "_CTCS", SUMX(CURRENTGROUP(),[@CTCS]))

RETURN
SUMX(_Union,IF([_CTCS] > 1,1,0))

 

 

My result

NilR_0-1696295853826.png

 

Expected result:

NilR_1-1696296045258.png

 

 

How to re-write SAMEPERIODLASTYEAR() within Summarize function? Thanks!

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @NilR ,

 

 

Here are the steps you can follow:

 

1. Create measure.

Measure =
IF(
    YEAR(MAX('Table'[DATE]))=YEAR(TODAY()),
SUMX(
    FILTER(ALL('Table'),
    'Table'[ID]=MAX('Table'[ID])&&
YEAR('Table'[DATE])=YEAR(MAX('Table'[DATE]))-1&&
MONTH('Table'[DATE])=MONTH(MAX('Table'[DATE]))),[MBR_CTCS])
+ MAX('Table'[MBR_CTCS]),BLANK())

2. Result:

vyangliumsft_0-1696514521796.png

 

 

Best Regards,

Liu Yang

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

8 REPLIES 8
v-yangliu-msft
Community Support
Community Support

Hi  @NilR ,

 

 

Here are the steps you can follow:

 

1. Create measure.

Measure =
IF(
    YEAR(MAX('Table'[DATE]))=YEAR(TODAY()),
SUMX(
    FILTER(ALL('Table'),
    'Table'[ID]=MAX('Table'[ID])&&
YEAR('Table'[DATE])=YEAR(MAX('Table'[DATE]))-1&&
MONTH('Table'[DATE])=MONTH(MAX('Table'[DATE]))),[MBR_CTCS])
+ MAX('Table'[MBR_CTCS]),BLANK())

2. Result:

vyangliumsft_0-1696514521796.png

 

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

very smart, thank you!

amitchandak
Super User
Super User

@NilR , all time intelligence fucntion work on Filter/row context. So when you use them in calculated data  table where filter context and row context can not apply  , it take the last date and start building the data.

So not the best function to use in in table

 

In table you can add column like

 

New column =

var _date = [Date]

return

sumx(filter(Table, Table[Date] = date(Year(_date)-1, month(_date), day(_date) )) , [Value])

Time Intelligent is set and working for Current Selected year, but I need to summarize and the SPLY function is not working in Summarize!

Hi,

Share some data, exlplain the question and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks for helping:

 

GPIDDATEMBR_CTCS
360007201/01/20221
360007202/01/20221
360007203/01/20220
360007204/01/20221
360007205/01/20221
360007206/01/20221
360007207/01/20221
360007208/01/20221
360007209/01/20221
360007210/01/20221
360007211/01/20221
360007212/01/20221
360007201/01/20231
360007202/01/20231
360007203/01/20231
360007204/01/20231
360007205/01/20231
360010601/01/20221
360010602/01/20221
360010603/01/20221
360010604/01/20221
360010605/01/20221
360010601/01/20231
360010602/01/20231
360010603/01/20231
360010604/01/20231
360010605/01/20231

Hi,

I read your original post and have just not been able to understand your requirement.  Please explain the question clearly and show the the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Trying to combine the result of Prev year and current Year values per month!

NilR_0-1696340508483.png

 

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.