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.
Hello,
The measure calculates sliced period's values, but I'd need to compare it with previous period. I've come this far, but since the slicer says `this month`, then it won't show the past months, given this measure.
TotalVpago_pcveicul_Comparison =
VAR SelectedFilter =
FILTER(
pclanc,
pclanc[CODCONTA] IN
CALCULATETABLE(
VALUES(pcconta[CODCONTA]),
pcconta[GRUPOCONTA] IN {501, 510},
NOT(ISBLANK(pcconta[CODCONTAMASTER])),
pcconta[CODCONTAMASTER] IN
CALCULATETABLE(
VALUES(pcveicul[CODVEICULO]),
pcveicul[CODLOCALIZACAO] = 1
)
)
)
VAR SelectedPeriodVPAGO =
CALCULATE(
SUM(pclanc[VPAGO]),
SelectedFilter
)
VAR PreviousPeriodVPAGO =
IF(
HASONEVALUE(pclanc[Date]), // Check if there's a single date value in the drill-through filter
CALCULATE(
SUM(pclanc[VPAGO]),
SAMEPERIODLASTYEAR(pclanc[Date]),
SelectedFilter
),
BLANK() // Return blank when there's no single date value (i.e., drill-through filter removed)
)
RETURN
SelectedPeriodVPAGO + PreviousPeriodVPAGO
This is what it shows, but I'd like it to show previous months and their comparisons from last year's months.
Appreciate any help!
Hey @antoniosantos,
i recommend reading this article: https://www.daxpatterns.com/time-patterns/
The article contains almost everything one needs to know about date/time related calculations. It also explains why these type of calculations require a dedicated data table (the first step to a star schema).
Hopefully, this gets you started.
Regards,
Tom
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 |
---|---|
105 | |
105 | |
88 | |
73 | |
66 |
User | Count |
---|---|
124 | |
113 | |
98 | |
81 | |
72 |