March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
Register NowGet certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now
Hi,
I am using below dax expression:
Solved! Go to Solution.
@sandip , try this DAX code:
totalGrossPurchase = VAR vDate = DATE ( YEAR ( SELECTEDVALUE ( CAL4[Current_End] ) ), MONTH ( SELECTEDVALUE ( CAL4[Current_End] ) ), 01 ) VAR v11MonthsBeforDt = DATE ( YEAR ( vDate ), MONTH ( vDate ) - 11, DAY ( vDate ) ) VAR v11MonthsBeforMonthName = TRIM ( FORMAT ( v11MonthsBeforDt, "YYYY-MMM" ) ) VAR v10MonthsBeforDt = DATE ( YEAR ( vDate ), MONTH ( vDate ) - 10, DAY ( vDate ) ) VAR v10MonthsBeforMonthName = TRIM ( FORMAT ( v10MonthsBeforDt, "YYYY-MMM" ) ) VAR v9MonthsBeforDt = DATE ( YEAR ( vDate ), MONTH ( vDate ) - 9, DAY ( vDate ) ) VAR v9MonthsBeforMonthName = TRIM ( FORMAT ( v9MonthsBeforDt, "YYYY-MMM" ) ) VAR Result = CALCULATE ( SUM ( 'SAVO_QBR_TEMP'[TOTAL GROSS SALES] ), Dates[YearMonthText] IN { v11MonthsBeforMonthName, v10MonthsBeforMonthName, v9MonthsBeforMonthName } ) RETURN Result
I kept everything the same, and then added a new variable Result that does what you're looking for.
You could probably build a similar filter only using the date column to get only the dates between 9 and 11 months before the selected period, that may be a little faster.
@sandip , try this DAX code:
totalGrossPurchase = VAR vDate = DATE ( YEAR ( SELECTEDVALUE ( CAL4[Current_End] ) ), MONTH ( SELECTEDVALUE ( CAL4[Current_End] ) ), 01 ) VAR v11MonthsBeforDt = DATE ( YEAR ( vDate ), MONTH ( vDate ) - 11, DAY ( vDate ) ) VAR v11MonthsBeforMonthName = TRIM ( FORMAT ( v11MonthsBeforDt, "YYYY-MMM" ) ) VAR v10MonthsBeforDt = DATE ( YEAR ( vDate ), MONTH ( vDate ) - 10, DAY ( vDate ) ) VAR v10MonthsBeforMonthName = TRIM ( FORMAT ( v10MonthsBeforDt, "YYYY-MMM" ) ) VAR v9MonthsBeforDt = DATE ( YEAR ( vDate ), MONTH ( vDate ) - 9, DAY ( vDate ) ) VAR v9MonthsBeforMonthName = TRIM ( FORMAT ( v9MonthsBeforDt, "YYYY-MMM" ) ) VAR Result = CALCULATE ( SUM ( 'SAVO_QBR_TEMP'[TOTAL GROSS SALES] ), Dates[YearMonthText] IN { v11MonthsBeforMonthName, v10MonthsBeforMonthName, v9MonthsBeforMonthName } ) RETURN Result
I kept everything the same, and then added a new variable Result that does what you're looking for.
You could probably build a similar filter only using the date column to get only the dates between 9 and 11 months before the selected period, that may be a little faster.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
Check out the November 2024 Power BI update to learn about new features.
User | Count |
---|---|
118 | |
96 | |
87 | |
71 | |
62 |
User | Count |
---|---|
138 | |
115 | |
115 | |
99 | |
98 |