Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi dears,
I have a issue with comparasion. Let me explain situation, let's go with data example from excel:
I want to calculate previous period, it's not any problem with 1 month selected, we can do this with sereval ways, and i already handle with this.
But when i try to select 2 month, if i use same formula, i get result with compairing 2 month vs 1 month, for example i select Apr'21 & May'21 i get previous period as Mar'21 only.
What i want: for example when I will select Apr'21 & May'21, I want that this period was compared with Feb'21 & Mar'21.
Which formula and how i must to use to get this result?
Thanks in advance.
Hi to everyone,
I'm solve my problem, and find solution which fully what i want.
Just want to share code below, maybe it will be usefull for someone, if you have questions let me know, code not perfect but it's solve my problem, and I'm only started working with Power BI.
HI @Isgandar_B,
You can add variable to get the selected month count and use it as offset in Dax expressions for previous period calculations.
Regards,
Xiaoxin Sheng
Hi thanks for your reply, yes i think so, logic is clear
I need formula which will determine 2 previous month of selected period, so how i can write this formula, could you help me with guidance (some topics or videos maybe)
i need that formula dynamically understand that if i selected Mar'23 & Apr'23 previous period must ve Jan'23 & Feb'23
HI @Isgandar_B,
You can try to use the following measure formula if it suitable for your requirement:
previous by selection =
VAR _offset =
COUNTROWS (
DISTINCT (
SELECTCOLUMNS (
VALUES ( NewTable[Date] ),
"YMonth",
YEAR ( [Date] ) * 100
+ MONTH ( [Date] )
)
)
)
VAR currDate =
MAX ( Table[Date] )
VAR prevDate =
DATE ( YEAR ( currDate ), MONTH ( currDate ) - _offset, DAY ( currDate ) )
VAR prevValue =
CALCULATE (
SUM ( Table[Value] ),
FILTER ( ALLSELECTED ( Table ), [Date] = prevDate )
)
RETURN
DIVIDE ( SUM ( Table[Value] ) - prevValue, prevValue )
Regards,
Xiaoxin Sheng
Thanks for your reply, but issue is that i need currdate not a max in date table, i need period which will be selected by user.
And second issue is that some times it can be 2 month selected, but another case 4-6-8 month, 2 month i write just for example.
User | Count |
---|---|
76 | |
74 | |
61 | |
61 | |
45 |
User | Count |
---|---|
108 | |
103 | |
93 | |
83 | |
64 |