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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
EdouardPBI
Frequent Visitor

Disconnected period ytd

Hello everyone,

My problem concerns the YTD.

I have 3 tables: Accounting (with date, account number, balance, company name), Date (a standard date table), and a third table, Fiscal Period.

Example:

Company 1_ 01/01/2022 - 31/12/2022

Company 1_ 01/01/2023 - 30/06/2022

Company 2_ 01/06/2002 - 01/07/2022

 

 

The Accounting table and Date tables are related to each other.

I have created the following measure:

 

 

comptaYTD =

var ste = SELECTEDVALUE(SOCIETE[COD_STE])
var currentdate = max('Calendar'[Date])

var DebutExercice = CALCULATE(min('Exercice Groupe'[Debut Exercice]), filter('Exercice Groupe',currentdate>='Exercice Groupe'[Debut Exercice] && currentdate<='Exercice Groupe'[Fin exercice]) ,filter('Exercice Groupe', 'Exercice Groupe'[Code STE] = ste))

var FinExercice = CALCULATE(max('Exercice Groupe'[Fin exercice]), filter('Exercice Groupe',currentdate>='Exercice Groupe'[Debut Exercice] && currentdate<='Exercice Groupe'[Fin exercice]) ,filter('Exercice Groupe', 'Exercice Groupe'[Code STE] = ste))

var result = CALCULATE([compta], filter(COMPTA,COMPTA[Date compta] >=DebutExercice && COMPTA[Date compta] <= FinExercice))
return

result

 

 

I am able to retrieve the correct period "beginning of the year" and "end of the year" for the selected company, but the YTD calculation is not working.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@EdouardPBI

If you only need YTD you can consider  a measure like

 

YTD Sales =
Switch(Max(Table[Company]) ,
"Company 1" , CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31")),
"Company 2" , CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"06/30")),
"Company 3" , CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"9/30"))
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

3 REPLIES 3
EdouardPBI
Frequent Visitor

yes ! thanks you very much, 

 

but in my case, there is a case where a companies has a 15 month fiscal year 

 

I try with a duplicate date table (one calendar for each companies and i append all in one table)

 

thks a lot

 

amitchandak
Super User
Super User

@EdouardPBI

If you only need YTD you can consider  a measure like

 

YTD Sales =
Switch(Max(Table[Company]) ,
"Company 1" , CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31")),
"Company 2" , CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"06/30")),
"Company 3" , CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"9/30"))
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
EdouardPBI
Frequent Visitor

anybody have a idea

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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