Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hola, como estan?
Estoy necesitando poder realizar variaciones de cantidad de ventas en base a un filtro de fecha. Por ejemplo si en el filtro tengo seleccionado un mes que de la variacion respecto del mes anterior, si esta seleccionada un año me muestre la variación del año anterior, pero tambien necesito si esta seleccionado un día en el filtro me de la variacion con el dia anterior o si esta seleccionado en el filtro una semana que me muestre la variación respecto de la semana anterior, todo en base al mismo filtro. Es decir el periodo "-1" de lo que este filtrado.
Alguien sabe como realizarlo?
Muchas gracias!
Solved! Go to Solution.
Hi @AgustinE ,
Based on your description, I created simple samples and you can check the results as follows:
Original Table:
By year:
By month:
By Week:
DimDate =
ADDCOLUMNS (
CALENDARAUTO (),
"Year", YEAR ( [Date] ),
"Month", FORMAT ( [Date], "MMMM" ),
"MonthSort", MONTH ( [Date] ),
"Day", DAY ( [Date] ),
"DayName", FORMAT ( [Date], "DDDD" ),
"WeekDay", WEEKDAY ( [Date],2 ),
"WeekStart",
[Date] - WEEKDAY ( [Date], 2 ) + 1
)
Last=
SWITCH (
TRUE (),
DISTINCTCOUNT ( DimDate[Year] ) = 1
&& DISTINCTCOUNT ( DimDate[Month] ) = 12, CALCULATE ( SUM ( 'Table'[Value] ), SAMEPERIODLASTYEAR ( DimDate[Date] ) ),
DISTINCTCOUNT ( DimDate[Month] ) = 1
&& DISTINCTCOUNT ( DimDate[WeekStart] ) > 1, CALCULATE ( SUM ( 'Table'[Value] ), PREVIOUSMONTH ( DimDate[Date] ) ),
DISTINCTCOUNT ( DimDate[WeekStart] ) = 1,
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( ALL ( DimDate ), DimDate[WeekStart] = MAX ( DimDate[WeekStart] ) - 7 )
),
CALCULATE ( SUM ( 'Table'[Value] ) )
)
An attachment for your reference. Hope it helps!
Best regards,
Community Support Team_ Scott Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi @AgustinE ,
Based on your description, I created simple samples and you can check the results as follows:
Original Table:
By year:
By month:
By Week:
DimDate =
ADDCOLUMNS (
CALENDARAUTO (),
"Year", YEAR ( [Date] ),
"Month", FORMAT ( [Date], "MMMM" ),
"MonthSort", MONTH ( [Date] ),
"Day", DAY ( [Date] ),
"DayName", FORMAT ( [Date], "DDDD" ),
"WeekDay", WEEKDAY ( [Date],2 ),
"WeekStart",
[Date] - WEEKDAY ( [Date], 2 ) + 1
)
Last=
SWITCH (
TRUE (),
DISTINCTCOUNT ( DimDate[Year] ) = 1
&& DISTINCTCOUNT ( DimDate[Month] ) = 12, CALCULATE ( SUM ( 'Table'[Value] ), SAMEPERIODLASTYEAR ( DimDate[Date] ) ),
DISTINCTCOUNT ( DimDate[Month] ) = 1
&& DISTINCTCOUNT ( DimDate[WeekStart] ) > 1, CALCULATE ( SUM ( 'Table'[Value] ), PREVIOUSMONTH ( DimDate[Date] ) ),
DISTINCTCOUNT ( DimDate[WeekStart] ) = 1,
CALCULATE (
SUM ( 'Table'[Value] ),
FILTER ( ALL ( DimDate ), DimDate[WeekStart] = MAX ( DimDate[WeekStart] ) - 7 )
),
CALCULATE ( SUM ( 'Table'[Value] ) )
)
An attachment for your reference. Hope it helps!
Best regards,
Community Support Team_ Scott Chang
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Sounds straightforward. What have you tried and where are you stuck?
User | Count |
---|---|
93 | |
85 | |
76 | |
66 | |
62 |
User | Count |
---|---|
110 | |
96 | |
95 | |
64 | |
57 |