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,
Can someone please send a sample pbi code or a dax code that will allow me to show 1. direct traffic 2. Organic into the previous year column. I am using a matrix table in PBI just wondered if anyone knows how to do this
Thanks
Solved! Go to Solution.
Hi,
try to create a measure like this:
DirectTrafficPY =
CALCULATE(
SUM(DirectTraffic)
,SAMEPERIODLASTYEAR(<dates>)
)
The same for the other measure.
If i help you mark this answer as Solution.
Hi @HarryB ,
The SAMEPERIODLASTYEAR function provided by @lucadelicio is a good choice.
Also in my testing, create a date table and put it in a one-to-many relationship with your data table. Then use the Dateadd function to find the value corresponding to the previous year.
Date =
ADDCOLUMNS (
CALENDAR ( DATE ( 2023, 01, 01 ), DATE ( 2024, 12, 31 ) ),
"Year", YEAR ( [Date] ),
"Quarter", ROUNDUP ( MONTH ( [Date] ) / 3, 0 ),
"Month", FORMAT(MONTH ( [Date] ),"mmmm"),
"Week", WEEKNUM ( [Date] ),
"Year-Qur",
YEAR ( [Date] ) & "Q"
& ROUNDUP ( MONTH ( [Date] ) / 3, 0 ),
"Year-Mon",
YEAR ( [Date] ) * 100
+ MONTH ( [Date] ),
"Year-Week",
YEAR ( [Date] ) * 100
+ WEEKNUM ( [Date], 2 ),
"Weekday", WEEKDAY ( [Date], 2 )
)
M_ = SUM('Table'[Direct Traffic])
Pre_year = CALCULATE([M_],DATEADD('Date'[Date],-1,YEAR))
Best Regards,
Adamk Kong
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
try to create a measure like this:
DirectTrafficPY =
CALCULATE(
SUM(DirectTraffic)
,SAMEPERIODLASTYEAR(<dates>)
)
The same for the other measure.
If i help you mark this answer as Solution.
Hi @lucadelicio
Thank you for your response.
I tried your solution but it did not work for me.
Would you happen to know what might be going on here My 'Source' is group with 2 sources.
You forgt ) after SUM function
User | Count |
---|---|
96 | |
87 | |
78 | |
72 | |
68 |
User | Count |
---|---|
113 | |
105 | |
84 | |
65 | |
64 |