The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
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.
Solved! Go to Solution.
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"))
)
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
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"))
)
anybody have a idea
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
113 | |
80 | |
78 | |
47 | |
40 |
User | Count |
---|---|
149 | |
115 | |
67 | |
64 | |
58 |