Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
bo_afk
Post Patron
Post Patron

Return dates only where visits exist for a category

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

1 ACCEPTED SOLUTION

In your case, the best solution will be to create additional columns that will help us build the measure.

 

Ex1.png

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! 😀

View solution in original post

5 REPLIES 5
lkalawski
Memorable Member
Memorable Member

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.

 

YearMonthVisitsDevice
2019March764Desktop
2019April598Desktop
2019May984Desktop
2019June532Desktop
2019July637Desktop
2019August112Mobile
2019August499Desktop
2019September158Mobile
2019September530Desktop
2019October201Mobile
2019October631Desktop

In your case, the best solution will be to create additional columns that will help us build the measure.

 

Ex1.png

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! 😀

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.