Reply
mateoc15
Helper II
Helper II
Partially syndicated - Outbound

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

Syndicated - Outbound

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

Syndicated - Outbound

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

Syndicated - Outbound

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

 

 



 

avatar user

Helpful resources

Announcements
March PBI video - carousel

Power BI Monthly Update - March 2025

Check out the March 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)