Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hi Community
I am asking for your help with a DAX measure i cant seem to figure out how to put together. Here is what i require.
I want to create a bar chart that could look similar to the snippet i provided. (it shows year to date values from current fiscal year 2024-25) and four years back.
However, i want to create a DAX measure that shows year to date, for my current fiscal year, i have a measure for that, where it takes into consideration my month selected in a slicer. Anything that is not current fiscal year should return the full year and disregard the month.
I hope someone can help me provide what the code would look like to achieve this.
Solved! Go to Solution.
Hi @Nicpet0 ,
I create a table as you mentioned.
Then I create a measure and here is the DAX code.
Measure =
VAR _CurrentFY_YTD =
CALCULATE ( SUM ( 'Table'[Amount] ), DATESYTD ( 'Table'[Date], "6/30" ) )
VAR _FullYear_PreviousYears =
CALCULATE (
SUM ( 'Table'[Amount] ),
ALLEXCEPT ( 'Table', 'Table'[FiscalYear] )
)
RETURN
IF (
MAX ( 'Table'[FiscalYear] ) = "2024-25",
_CurrentFY_YTD,
_FullYear_PreviousYears
)
So when I select the slicer, it will get what you want in the bar chart.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Nicpet0 ,
I create a table as you mentioned.
Then I create a measure and here is the DAX code.
Measure =
VAR _CurrentFY_YTD =
CALCULATE ( SUM ( 'Table'[Amount] ), DATESYTD ( 'Table'[Date], "6/30" ) )
VAR _FullYear_PreviousYears =
CALCULATE (
SUM ( 'Table'[Amount] ),
ALLEXCEPT ( 'Table', 'Table'[FiscalYear] )
)
RETURN
IF (
MAX ( 'Table'[FiscalYear] ) = "2024-25",
_CurrentFY_YTD,
_FullYear_PreviousYears
)
So when I select the slicer, it will get what you want in the bar chart.
Best Regards
Yilong Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Nicpet0
you can write a measure as follows:
measure YTD := var this_year = max( dimdate[year]) -- or you also can write year(today()), depend to your data
return
calculate(sum(quantity) , filter (all(your_table) , your_table[year] = this_year))
If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
20 | |
13 | |
12 | |
11 | |
8 |