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
rajanimaddala
Helper II
Helper II

Last Year value

Hi

   I have a slicer which has CampaignYear values and the data table(CustTrans) which has CampaignYear,CustomerId, TransDate and other data fields

 

I have selected 2021 in the slicer.

 

I am returning CustomerCount  YTD

TotalCustomers = CALCULATE(COUNT(CustomerId), FILTER(TransDate <= DATE(YEAR(TODAY()), MONTH(TODAY()), DAY(TODAY())))

 

This is working fine.

 

Now, I need to find the LY count for the same period.

 

TotalCustomers LY =

var PrevCampaignYear = SELECTEDVALUE(CampignYear)-1

RETURN CALCULATE(DISTINCTCOUNT(CustomerUid), FILTER(ALL(CustTRans) CustTRans(CampaignYear = PrevCampaignYear) && CustTrans(TransDate) <= DATE(YEAR(TODAY())-1, MONTH(TODAY()), DAY(TODAY()))))

 

I tried to display in the table visual with CampaignYear, TotalCustomers, TotalCustomers LY

 

Current year total is correct but LY total displaying the value for all CampaignYears even I have selected 2021 in the slicer?

 

It is killing me. I have 1 to Many relationship between these two tables

 

Please advise

 

Thanks

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

I have monthly data for economic variables and I want to see their evolution by month, but I do not know how to create that measure

V-lianl-msft
Community Support
Community Support

Hi @rajanimaddala ,

 

Please refer to similar threads

https://community.powerbi.com/t5/Desktop/YTD-last-year-DAX/td-p/108482 

 

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

amitchandak
Super User
Super User

@rajanimaddala , refer this formula to get last year data

 

example

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
This year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-1,Year)),"12/31"))
Last to last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-2,Year),"12/31"))
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

refer this too:Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a

sanalytics
Solution Supplier
Solution Supplier

@rajanimaddala 

Can you please share some dummy data and power bi model so that we can try..

Regards,

sanalytics

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.