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.
Hi,
First of all, my dataset is in year and month level. I dont have any dates.
For calculating YTD, MTD and QTD, i have taken the first date of all months.
Second thing is, my data is based on fiscal year starting from october.
I have used ,
Solved! Go to Solution.
You need to make slight changes in data model.
1) Create a date column from year and month
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddRLjsMwCADQu2TdBf/PLWZf9f7XmODWmk4gCyuRnzBghTyfxw8ej4MA43xYLWY+Xo8OLh4jEGjOwNDBzyXiNAJF2AxkMoKKzmDun6PokpxDG9TCQJ9BeAYDhxkUeARS7MlzdY693Fzl+hzhuq/kCxAqJI1uxDNncdn5+SLKLl3wHUOzmAvPggiDVDXIeSMK+wo+Uu3XYWLBI5DyDWTgG+QPKgf77v8CZPuaL+C6q/qCSqdmPMK5TyOwQz9K1qDw5wPT/4AoNAIJeIN61RQcwVNvIoS4Qc21IMsIZtFzrH+HczZYcw0SI2iYjuCWvao1cxS9jwIW7+UuIDqTv34B", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Product = _t, Year = _t, Month = _t, Amount = _t]), Date = Table.AddColumn(Source, "Date", each #date(Number.From([Year]),Number.From([Month]),1)), ChangedType = Table.TransformColumnTypes(Date,{{"Product", type text}, {"Year", Int64.Type}, {"Month", Int64.Type}, {"Amount", Int64.Type}, {"Date", type date}}) in ChangedType
2) Use below measure to calculate YTD values
Measure = CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Date]>=DATE(2018,10,1) && 'Table'[Date]<=TODAY()))
3) Similarly you can create other measures
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You need to make slight changes in data model.
1) Create a date column from year and month
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddRLjsMwCADQu2TdBf/PLWZf9f7XmODWmk4gCyuRnzBghTyfxw8ej4MA43xYLWY+Xo8OLh4jEGjOwNDBzyXiNAJF2AxkMoKKzmDun6PokpxDG9TCQJ9BeAYDhxkUeARS7MlzdY693Fzl+hzhuq/kCxAqJI1uxDNncdn5+SLKLl3wHUOzmAvPggiDVDXIeSMK+wo+Uu3XYWLBI5DyDWTgG+QPKgf77v8CZPuaL+C6q/qCSqdmPMK5TyOwQz9K1qDw5wPT/4AoNAIJeIN61RQcwVNvIoS4Qc21IMsIZtFzrH+HczZYcw0SI2iYjuCWvao1cxS9jwIW7+UuIDqTv34B", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Product = _t, Year = _t, Month = _t, Amount = _t]), Date = Table.AddColumn(Source, "Date", each #date(Number.From([Year]),Number.From([Month]),1)), ChangedType = Table.TransformColumnTypes(Date,{{"Product", type text}, {"Year", Int64.Type}, {"Month", Int64.Type}, {"Amount", Int64.Type}, {"Date", type date}}) in ChangedType
2) Use below measure to calculate YTD values
Measure = CALCULATE(SUM('Table'[Amount]),FILTER('Table','Table'[Date]>=DATE(2018,10,1) && 'Table'[Date]<=TODAY()))
3) Similarly you can create other measures
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
99 | |
80 | |
64 | |
57 |
User | Count |
---|---|
145 | |
110 | |
91 | |
84 | |
66 |