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 All,
I have below table:
I want to calculate SUM of Value for latest Financial Year, for every year grouped by Country and Businees Vertical for Scenario = "Forecasted - Yearly"
I am currently using this DAX query, but it is not working right:
Measure =
VAR LastNonBlankDate =
CALCULATE (
MAXA ( 'Planned and Realized'[Date] ),
FILTER (
ALL ( 'Planned and Realized' ),
'Planned and Realized'[Date] <= MAXA ( 'Planned and Realized'[Date] )
&& 'Planned and Realized'[Value] > 0
&& 'Planned and Realized'[Scenario] = "Forecasted - Yearly"
)
)
RETURN
CALCULATE (
SUMX ( 'Planned and Realized', 'Planned and Realized'[Value] ),
FILTER (
ALL ( 'Planned and Realized' ),
'Planned and Realized'[Date] = LastNonBlankDate
&& 'Planned and Realized'[Scenario] = "Forecasted - Yearly"
&& 'Planned and Realized'[Account] = "Revenue"
)
)
But it is giving me wrong result, see this :
I also tried to create a new table with DAX, but I could not get data for all years, it only shows for latest year:
Latest Forecast revenue =
VAR LastNonBlankDate =
CALCULATE (
MAXA ( 'Planned and Realized'[Date] ),
FILTER (
ALL ( 'Planned and Realized' ),
'Planned and Realized'[Date] <= MAXA ( 'Planned and Realized'[Date] )
&& 'Planned and Realized'[Value] > 0
&& 'Planned and Realized'[Scenario] = "Forecasted - Yearly"
)
)
RETURN
SUMMARIZE (
FILTER (
ALL ( 'Planned and Realized' ),
'Planned and Realized'[Date] = LastNonBlankDate
&& 'Planned and Realized'[Scenario] = "Forecasted - Yearly"
&& 'Planned and Realized'[Account] = "Revenue"
),
'Planned and Realized'[Country],
'Planned and Realized'[Date],
'Planned and Realized'[Scenario],
'Planned and Realized'[Business Vertical],
"Total Sales", SUM ( 'Planned and Realized'[Value] )
)
See the result:
Table:
Result:
How can I get it working for all the years, and not only latest year ?
Thanks in advance
Solved! Go to Solution.
@Anonymous , You can use time intelligence and date table
Three measures like
measure =
CALCULATE (
SUMX ( 'Planned and Realized', 'Planned and Realized'[Value] ),
FILTER (
( 'Planned and Realized' ),
'Planned and Realized'[Scenario] = "Forecasted - Yearly"
&& 'Planned and Realized'[Account] = "Revenue"
)
)
YTD = CALCULATE([measure],DATESYTD('Date'[Date],"12/31"))
Last YTD = CALCULATE([measure],DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
@Anonymous , You can use time intelligence and date table
Three measures like
measure =
CALCULATE (
SUMX ( 'Planned and Realized', 'Planned and Realized'[Value] ),
FILTER (
( 'Planned and Realized' ),
'Planned and Realized'[Scenario] = "Forecasted - Yearly"
&& 'Planned and Realized'[Account] = "Revenue"
)
)
YTD = CALCULATE([measure],DATESYTD('Date'[Date],"12/31"))
Last YTD = CALCULATE([measure],DATESYTD(dateadd('Date'[Date],-1,Year),"12/31"))
Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA
Hi @amitchandak ,
Thanks for the reply, I managed to get most of my issue solved, but still one problem remains.
I think I fogot to mention in my original post, but what I exactly want is sum of values for the latest month in a financial year for all years.
So after your recommendation, I create a date table with starting month as October, and ending month September from 2017-2021, I managed to get different sum for different years, Country etc.
But for eg, if I have data till April 2021, this year, and I also have data for March, Feb etc in 2021, then I don't want to SUM data from March, feb etc, for this year, only SUM the data for latest Month in a Financial year, for every year. In screenshot below, I don't want to SUM March, but only April, as it is the only latest month available in that year
Hope you got my query.
Thanks.
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 |
---|---|
37 | |
25 | |
19 | |
14 | |
8 |
User | Count |
---|---|
69 | |
48 | |
44 | |
19 | |
15 |