Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello I have this dataset:
INDEX | ID PERSON | CARD TYPE | SUBSCRIPTION YEAR |
1 | A | FREE | 2018 |
2 | B | PREMIUM | 2018 |
3 | C | FREE | 2018 |
4 | D | PRO | 2018 |
5 | A | PREMIUM | 2019 |
6 | B | PRO | 2019 |
7 | C | PRO | 2019 |
8 | E | FREE | 2019 |
9 | D | FREE | 2020 |
10 | E | PRO | 2020 |
I would like to know for each year (from 2018 to 2019):
I need of course the other combinations, too.
HELP ME PLEASE!!!
Solved! Go to Solution.
Minor change required:
Change =
VAR __Current = [CARD TYPE]
VAR __Previous =
FILTER(
'Query1',
[ID PERSON] = EARLIER([ID PERSON]) &&
[INDEX] < EARLIER([INDEX])
)
VAR __LastID = MAXX(__Previous,[INDEX])
VAR __Last = IF(ISBLANK(__LastID),BLANK(),MAXX(FILTER('Query1',[INDEX] = __LastID),[CARD TYPE]))
RETURN
SWITCH(TRUE(),
ISBLANK(__Last),BLANK(),
__Current <> __Last, __Last & " to " & __Current,
BLANK()
)
I don't typically use an Index starting at 0 because of issues like this.
Please don't cross post.
Change =
VAR __Current = [CARD TYPE]
VAR __Previous =
FILTER(
'Table',
[ID PERSON] = EARLIER([ID PERSON]) &&
[INDEX] < EARLIER([INDEX])
)
VAR __LastID = MAXX(__Previous,[INDEX])
VAR __Last = MAXX(FILTER('Table',[INDEX] = __LastID),[CARD TYPE])
RETURN
SWITCH(TRUE(),
ISBLANK(__Last),BLANK(),
__Current <> __Last, __Last & " to " & __Current,
BLANK()
)
Thank you so much @Greg_Deckler, but it actually doesn't guess right the correct result
Moreover, it is strange but even if some row has blank ID Person, the formula returns some result.
How is it possible since I want to understand the same person which plan type he changed to?
Thank you for your patience.
Unclear @ivandelgra it seems to work just fine in the attached PBIX so perhaps there is something that you are not telling me. The code looks at the most recent Index for an ID PERSON. If the status is not the same, it logs it correctly. Otherwise, it puts in a blank. So this would handle people changing even within the same year. What are you expected results from the sample data?
INDEXID PERSONCARD TYPESUBSCRIPTION YEARChange
1 | A | FREE | 2018 | |
2 | B | PREMIUM | 2018 | |
3 | C | FREE | 2018 | |
4 | D | PRO | 2018 | |
5 | A | PREMIUM | 2019 | FREE to PREMIUM |
6 | B | PRO | 2019 | PREMIUM to PRO |
7 | C | PRO | 2019 | FREE to PRO |
8 | E | FREE | 2019 | |
9 | D | FREE | 2020 | PRO to FREE |
10 | E | PRO | 2020 | FREE to PRO |
Here attached the file with my data set after having integrated your formula.
I have filtered a single ID Person so you can note the error immediately.
Powerbi file:
https://drive.google.com/file/d/1GsWFg27PnacVkptezuTFSSIAVLSQL95E/view?usp=sharing
Dataset source:
https://drive.google.com/file/d/1QpMbP5tNbxN1UsfpQKaNg0RZWTmruQGQ/view?usp=sharing
Thank you @Greg_Deckler .
Minor change required:
Change =
VAR __Current = [CARD TYPE]
VAR __Previous =
FILTER(
'Query1',
[ID PERSON] = EARLIER([ID PERSON]) &&
[INDEX] < EARLIER([INDEX])
)
VAR __LastID = MAXX(__Previous,[INDEX])
VAR __Last = IF(ISBLANK(__LastID),BLANK(),MAXX(FILTER('Query1',[INDEX] = __LastID),[CARD TYPE]))
RETURN
SWITCH(TRUE(),
ISBLANK(__Last),BLANK(),
__Current <> __Last, __Last & " to " & __Current,
BLANK()
)
I don't typically use an Index starting at 0 because of issues like this.
@Greg_Deckler Is this the formula i would need for mine? my response to @amitchandak to confirm exactly what im trying to do
THANK YOU
@Greg_Deckler YOU ARE A GENIOUS!!! WOOOW!
I have made some minor change, too in order to include the result for people that does not change YoY.
Below you can find the final formula. thank you Greeeeeeeeeeeeg
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
17 | |
10 | |
10 | |
8 | |
6 |
User | Count |
---|---|
18 | |
16 | |
15 | |
12 | |
10 |