Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.