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
mateoc15
Advocate I
Advocate I

Measure for one data source weighted by another

I have a data set with one record per digital survey.   There are three different surveys.

Response IDSurveySurvey ScoreDate
1Desktop Browser501/1/2024
2Mobile Browser601/1/2024
3Mobile App1001/1/2024
4Mobile App901/1/2024
5Mobile App951/1/2024

 

I have site traffic data with a number of visitors for each platform for each day.

PlatformDateVisitors
Desktop Browser 1/1/20243000
Desktop Browser 1/2/20242500
Desktop Browser 1/3/20241500
Mobile Browser 1/1/20241000
Mobile Browser 1/2/2024600
Mobile Browser 1/3/2024400
Mobile App 1/1/2024100
Mobile App 1/2/2024500
Mobile App 1/3/20244000

 

The goal is to give a score for each date, but weighted based on the number of visitors to each platform.  For instance, the mobile  app had 3 great surveys with an average of 95.  However, mobile app only made up a very small percentage of the total traffic for 1/1/2024 (mobile app traffic is 100 of the 4100 visitors that day).

So I guess my model needs to join on both date and platform/survey name, but I'm not sure what the measure would look like, not even sure where to start.  Any help appreciated!

1 ACCEPTED SOLUTION
v-heq-msft
Community Support
Community Support

Hi @mateoc15 ,
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:

vheqmsft_0-1713408037471.png

vheqmsft_1-1713408053673.png

Create relationships between Survey and Platform

vheqmsft_2-1713408123863.png

Create meaures

Visitor equal to date = 
CALCULATE(
    MAX(Visitors[Visitors]),
    FILTER(
        Visitors,
        SELECTEDVALUE('Digital survey'[Date]) = Visitors[Date] && SELECTEDVALUE('Digital survey'[Survey]) = Visitors[Platform]
    )
)
Average score = 
VAR _sum = 
CALCULATE(
    SUM('Digital survey'[Survey Score]),
    ALLEXCEPT(
        'Digital survey',
        'Digital survey'[Survey]
    )
)
VAR _countRows =
 CALCULATE(
    COUNT('Digital survey'[Survey]),
    ALLEXCEPT(
        'Digital survey',
        'Digital survey'[Survey]
    )
)
RETURN
_sum/_countRows
weighted average score = 
 [Visitor equal to date]/
CALCULATE(
    SUMX(VALUES('Digital survey'[Survey]),[Visitor equal to date]),
    REMOVEFILTERS('Digital survey'[Survey])
)*[Average score]

Final output

vheqmsft_3-1713408195529.png

Best regards,

Albert He

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 



 

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Show the expected rsult clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-heq-msft
Community Support
Community Support

Hi @mateoc15 ,
Here some steps that I want to share, you can check them if they suitable for your requirement.
Here is my test data:

vheqmsft_0-1713408037471.png

vheqmsft_1-1713408053673.png

Create relationships between Survey and Platform

vheqmsft_2-1713408123863.png

Create meaures

Visitor equal to date = 
CALCULATE(
    MAX(Visitors[Visitors]),
    FILTER(
        Visitors,
        SELECTEDVALUE('Digital survey'[Date]) = Visitors[Date] && SELECTEDVALUE('Digital survey'[Survey]) = Visitors[Platform]
    )
)
Average score = 
VAR _sum = 
CALCULATE(
    SUM('Digital survey'[Survey Score]),
    ALLEXCEPT(
        'Digital survey',
        'Digital survey'[Survey]
    )
)
VAR _countRows =
 CALCULATE(
    COUNT('Digital survey'[Survey]),
    ALLEXCEPT(
        'Digital survey',
        'Digital survey'[Survey]
    )
)
RETURN
_sum/_countRows
weighted average score = 
 [Visitor equal to date]/
CALCULATE(
    SUMX(VALUES('Digital survey'[Survey]),[Visitor equal to date]),
    REMOVEFILTERS('Digital survey'[Survey])
)*[Average score]

Final output

vheqmsft_3-1713408195529.png

Best regards,

Albert He

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 



 

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.