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.
I have the following measure:
Previous Sales = IF(HASONEVALUE(DateDimension[Year]); CALCULATE(SUM(BI_Sales[Value]); DATEADD(DateDimension[DateKey]; -1; YEAR)); BLANK() )
And in my page, I have slicers for month and year, If user selects 2019 and 2018 the measure will work fine, my problem is when the user selects 2019 and 2017 or select just 2019 but 2 months, like January and May, note the months are not sequential.
Is there any way to verify if exists a contiguous selection to treat this case or correct this problem?
I have tried to use SAMEPERIODLASTYEAR.
Solved! Go to Solution.
Hi @gluizqueiroz,
I think you need to create a separate date table and then link your current table to the new date table.
Date table:
Date = CALENDAR(MIN('DateDimension'[DateKey]),MAX('DateDimension'[DateKey]))
And then you need to redefine this measure as shown below.
Measure:
Previous Sales = IF ( HASONEVALUE ( DateDimension[Year] ), CALCULATE ( SUM ( DateDimension[Value] ), FILTER ( ALL ( 'Date' ), YEAR ( 'Date'[Date] ) = YEAR ( MAX ( 'Date'[Date] ) ) - 1 && MONTH ( 'Date'[Date] ) = MONTH ( MAX ( 'Date'[Date] ) ) ) ), BLANK () )
Select [Date].Month from the data table as a slicer, the measure still works even if you select two months that are not sequential.
Best Regards,
Jack Chen
Hi @gluizqueiroz,
I think you need to create a separate date table and then link your current table to the new date table.
Date table:
Date = CALENDAR(MIN('DateDimension'[DateKey]),MAX('DateDimension'[DateKey]))
And then you need to redefine this measure as shown below.
Measure:
Previous Sales = IF ( HASONEVALUE ( DateDimension[Year] ), CALCULATE ( SUM ( DateDimension[Value] ), FILTER ( ALL ( 'Date' ), YEAR ( 'Date'[Date] ) = YEAR ( MAX ( 'Date'[Date] ) ) - 1 && MONTH ( 'Date'[Date] ) = MONTH ( MAX ( 'Date'[Date] ) ) ) ), BLANK () )
Select [Date].Month from the data table as a slicer, the measure still works even if you select two months that are not sequential.
Best Regards,
Jack Chen
Hey @v-shex-msft.
Your answer looks good, but I'm not have tried yet, when I try it, I came here to Accept or not your answer as correctly.
I not forget this post.
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 |
---|---|
113 | |
97 | |
84 | |
67 | |
60 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |