Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and a 50 percent discount on exams.
Get startedEarn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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
User | Count |
---|---|
87 | |
72 | |
69 | |
64 | |
54 |
User | Count |
---|---|
99 | |
91 | |
80 | |
74 | |
64 |