Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
In my data, I have visits to a website and a column for device, e.g. desktop and mobile.
The mobile site didn't go live until mid last year whereas the desktop site was live from the start of the year. How would I calculate the % of visits to the mobile site, only for the dates where this was live? i.e. only include dates where mobile visits >0.
Currently when I calculate this, it takes into account the whole year so the figure isn't totally correct and is lower than actual.
Thanks
afk
Solved! Go to Solution.
In your case, the best solution will be to create additional columns that will help us build the measure.
Measure:
Measure =
VAR _startmonth = Calculate(Min('Table'[YearMonth]),'Table'[Device] = "Mobile")
var totalVisits = Calculate(sum('Table'[Visits]),'Table'[YearMonth] >= _startmonth)
var mobileVisits = calculate(sum('Table'[Visits]) , 'Table'[Device] = "Mobile")
RETURN
mobileVisits/totalVisits
_startmonth = calculates the first month in which values for mobile appeared,
_totalvisits = calculates sum of only those values that are greater than or equal to.
Thanks to this, you don't take the whole period, only from the moment "Mobile" appears.
_______________
If I helped, please accept the solution and give kudos! 😀
Hi bo_afk,
Please provide an example of the measure you use for the calculation.
But you probably need to use the Calculate function and add a condition that will take the numbers for a given period.
Another solution may be to correctly set the relationship between the tables.
Please provide more details and I will try to help.
_______
If I helped, please accept the solution and give kudos! 😀
Hi @lkalawski, thanks for your response
Measure =
var totalVisits = sum(visits)
var mobileVisits = calculate(sum(visits) , device = 'mobile')
RETURN
mobileVisits/totalVisits
Could you also put an example of the data?
Based on what you have sent, I can say that totalVisits calculates the sum for all and it would be useful to use Calculate there, but I will be able to tell you more if send an example of data.
_______________
If I helped, please accept the solution and give kudos! 😀
Example data below. As you can see, mobile was only introduced in August.
Year | Month | Visits | Device |
2019 | March | 764 | Desktop |
2019 | April | 598 | Desktop |
2019 | May | 984 | Desktop |
2019 | June | 532 | Desktop |
2019 | July | 637 | Desktop |
2019 | August | 112 | Mobile |
2019 | August | 499 | Desktop |
2019 | September | 158 | Mobile |
2019 | September | 530 | Desktop |
2019 | October | 201 | Mobile |
2019 | October | 631 | Desktop |
In your case, the best solution will be to create additional columns that will help us build the measure.
Measure:
Measure =
VAR _startmonth = Calculate(Min('Table'[YearMonth]),'Table'[Device] = "Mobile")
var totalVisits = Calculate(sum('Table'[Visits]),'Table'[YearMonth] >= _startmonth)
var mobileVisits = calculate(sum('Table'[Visits]) , 'Table'[Device] = "Mobile")
RETURN
mobileVisits/totalVisits
_startmonth = calculates the first month in which values for mobile appeared,
_totalvisits = calculates sum of only those values that are greater than or equal to.
Thanks to this, you don't take the whole period, only from the moment "Mobile" appears.
_______________
If I helped, please accept the solution and give kudos! 😀
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
88 | |
68 | |
61 |
User | Count |
---|---|
150 | |
120 | |
100 | |
87 | |
68 |