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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

How to switch values between Calendar Year and Financial Year in the same visuals

I'm working on a project in that i need to create a Slicer for CY & FY ,based on filtering the the visuals has to change accordingly.

Futher i need to caluculate MTD,YTD caluculations .

i read in the community to create seperate visuals for both & add a bookmarks for CY &FY seperately,but our team not considering this approach .

1) Is this possible without creating two seperate visuals for CY & FY?

2) Will this can be acheive with measures?

3) Need to combine FY and CY ina table? if so, how to do it?  

 

please help

 

 

1 ACCEPTED SOLUTION
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

Firstly, You may create a calendar table , then create relationship between the fact data table and the calendar table on date field.

 

Calendar= CALENDARAUTO()

 

Secondly, you may create a new table named 'SlicerTable' by "Enter data", put the 'SlicerTable'[Selection] into Slicer visual to filter data.

128.png

 

 

 

Finally, you may create measures like DAX below, display the [Selected CY or PY] in someone visual.

 

YTD for CY = TOTALYTD(SUM(Table1[Sales]),'Calendar'[Date])



YTD for PY = CALCULATE(SUM(Table1[Sales]),SAMEPERIODLASTYEAR('Calendar'[Date]))



Selected CY or PY= SWITCH(SELECTEDVALUE('SlicerTable'[Selection]), "CY", [YTD for CY ], "PY", [YTD for PY ] )

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

2 REPLIES 2
v-xicai
Community Support
Community Support

Hi @Anonymous ,

 

Firstly, You may create a calendar table , then create relationship between the fact data table and the calendar table on date field.

 

Calendar= CALENDARAUTO()

 

Secondly, you may create a new table named 'SlicerTable' by "Enter data", put the 'SlicerTable'[Selection] into Slicer visual to filter data.

128.png

 

 

 

Finally, you may create measures like DAX below, display the [Selected CY or PY] in someone visual.

 

YTD for CY = TOTALYTD(SUM(Table1[Sales]),'Calendar'[Date])



YTD for PY = CALCULATE(SUM(Table1[Sales]),SAMEPERIODLASTYEAR('Calendar'[Date]))



Selected CY or PY= SWITCH(SELECTEDVALUE('SlicerTable'[Selection]), "CY", [YTD for CY ], "PY", [YTD for PY ] )

 

Best Regards,

Amy 

 

Community Support Team _ Amy

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

@Anonymous
https://community.powerbi.com/t5/Community-Blog/Creating-Financial-Calendar-Decoding-Date-and-Calendar-1-5-Power/ba-p/1187441

Cal year

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))

 

Year end at the march

 

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

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/

See if my webinar on Time Intelligence can help: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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