Get 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.
User | Count |
---|---|
115 | |
95 | |
87 | |
76 | |
65 |
User | Count |
---|---|
138 | |
113 | |
110 | |
98 | |
93 |