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.
Hello Everyone,
I'm new to this forum and need help with a DAX calculation. When I select a year in the slicer, I want to see the sales amount for the corresponding year of the previous year. If I select both a year and a month, I'm looking for the sales amount for the same month of the previous year. Additionally, if I choose the current month in the slicer, I want to see the total sales amount from the previous year up to the selected date which means till 23rd of Jan 2023.
If I select 2023 in year and Jan in month slicer I want to see the sales amount for the entire month of January 2022.
I've created a DAX formula that works correctly for the current month. However, when I select January 2023, the result only includes data until January 22, 2022. My goal is to retrieve the entire sales data for January 2022 when selecting January 2023 in the year and month slicers.
Here is my Dax
I appreciate any guidance or corrections to my DAX formula.
@Fowmy Thanks For your responce this is working fine for last years(if I select 2023 Jan I am getting correct result for 2022 Jan) but when I select current Month value is showing wrong and when I select feb 2024 I am getting huge amount My requirement is when I select current month the previous year value should get till the date. If I select Feb also I should get the value last year of till the date(Till Jan 23).
@PowerBigginer
Follow this patter, it caluclates the sales up to the date where there is sales for current and previous periods, it could be month, year, week and so on:
MoM =
VAR __CM = [Sales Amount]
VAR __Period = DATEADD( DATESBETWEEN( 'Date'[Date] , MIN( 'Date'[Date] ) , MAX( 'Sales'[Order Date] ) ) , -1 , YEAR )
VAR __LYSM = CALCULATE( [Sales Amount] ,__Period )
RETURN
__LYSM
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
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 |
---|---|
81 | |
75 | |
60 | |
37 | |
33 |
User | Count |
---|---|
102 | |
56 | |
52 | |
46 | |
40 |