The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a table that takes a snapshot of an environment of app labels every month. I want to be able to show the labels that were added or removed between one month to another. This is the query I have so far but its not working correctly.
ChangedAppLabels =
VAR CurrentMonthLabels =
SELECTCOLUMNS(
CALCULATETABLE(
'Zylo Trending',
'Zylo Trending'[DB Loading Date]
),
"App Label", 'Zylo Trending'[App Label], "DB Loading Date", 'Zylo Trending'[DB Loading Date]
)
VAR PreviousMonthLabels =
SELECTCOLUMNS(
CALCULATETABLE(
'Zylo Trending',
PREVIOUSMONTH('DateTable'[Date])
),
"App Label", 'Zylo Trending'[App Label], "DB Loading Date", 'Zylo Trending'[DB Loading Date]
)
VAR AddedLabels =
EXCEPT(CurrentMonthLabels, PreviousMonthLabels)
VAR RemovedLabels =
EXCEPT(PreviousMonthLabels, CurrentMonthLabels)
RETURN
DISTINCT(
UNION(
SELECTCOLUMNS(AddedLabels, "Change Type", "Added", "App Label", [App Label], "DB Loading Date", [DB Loading Date]),
SELECTCOLUMNS(RemovedLabels, "Change Type", "Removed", "App Label", [App Label], "DB Loading Date", [DB Loading Date])
)
)
// DISTINCT(EXCEPT(DISTINCT(CurrentMonthLabels), DISTINCT( PreviousMonthLabels)))
Hi @you7777
Can you please try below dax?
ChangedAppLabels =
VAR CurrentMonthLabels =
SELECTCOLUMNS(
FILTER(
'Zylo Trending',
'Zylo Trending'[DB Loading Date] = MAX('Zylo Trending'[DB Loading Date])
),
"App Label", 'Zylo Trending'[App Label],
"DB Loading Date", 'Zylo Trending'[DB Loading Date]
)
VAR PreviousMonthLabels =
SELECTCOLUMNS(
FILTER(
'Zylo Trending',
'Zylo Trending'[DB Loading Date] =
EDATE(MAX('Zylo Trending'[DB Loading Date]), -1)
),
"App Label", 'Zylo Trending'[App Label],
"DB Loading Date", 'Zylo Trending'[DB Loading Date]
)
VAR AddedLabels =
EXCEPT(CurrentMonthLabels, PreviousMonthLabels)
VAR RemovedLabels =
EXCEPT(PreviousMonthLabels, CurrentMonthLabels)
RETURN
UNION(
SELECTCOLUMNS(
AddedLabels,
"Change Type", "Added",
"App Label", [App Label],
"DB Loading Date", [DB Loading Date]
),
SELECTCOLUMNS(
RemovedLabels,
"Change Type", "Removed",
"App Label", [App Label],
"DB Loading Date", [DB Loading Date]
)
)
This revised query should correctly identify added or removed labels between snapshots.
Did I answer your question? Mark my post as a solution, this will help others!
If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂
Kind Regards,
Poojara
Data Analyst | MSBI Developer | Power BI Consultant
Consider Subscribing my YouTube for Beginners/Advance Concepts: https://youtube.com/@biconcepts?si=04iw9SYI2HN80HKS
So this only returned the last 2 months, and it returned all the apps (i just turned it into a count for better understanding). Rather, I need just the labels that are different between each month to be returned, on a month to month basis, ideally showing what was added and what was removed. In this case, it should just show 10 labels for the month of december.
Hi @you7777
We are unable to provide you with complete advice based on the information you provided, can you provide some sample data (hide the private message) and the output you want so that can provide more suggestion for you.
Best Regards!
Yolo Zhu
this was the output of my original query. Again, these are string labels but i've turned them into a count for a quick summary/data privacy. I want to be able to show which labels are different month to month. If possible - I'd also like to show which labels were added and which ones were removed.