Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hello all!
I'm currently in need of help for this problem:
I have this example table here, that represents a user interaction in a page i'm currently working on, as represented below:
| module name | module event | views | clicks |
| report_a | back | 5 | |
| report_a | forward | 2 | |
| report_a | screen | 10 |
And I need to calculate the people that acessed a page and clicked on a button, and make a percentage of it.
Since i know that the person that has clicked on a button HAS accessed the page, I do not really need its views in the table, but i need to grab that number and divide by clicks of that button. So it becomes somwthing like this:
| module name | module event | clicks | CTR |
| report_a | back | 5 | 50% |
| report_a | forward | 2 | 20% |
Is it possible to do something like this in powerBI?
Thanks in advance!
Solved! Go to Solution.
@tone_radeu
I created table:
The CRT Measure:
CTR =
VAR __Module = SELECTEDVALUE( Table24[module name] )
VAR __Clicks = SUM(Table24[clicks])
VAR __Views =
CALCULATE(
SUM(Table24[views]),
Table24[module name] = __Module,
Table24[module event] = "screen"
)
VAR __Result = DIVIDE( __Clicks,__Views)
RETURN
__Result
Result:
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@tone_radeu
I created table:
The CRT Measure:
CTR =
VAR __Module = SELECTEDVALUE( Table24[module name] )
VAR __Clicks = SUM(Table24[clicks])
VAR __Views =
CALCULATE(
SUM(Table24[views]),
Table24[module name] = __Module,
Table24[module event] = "screen"
)
VAR __Result = DIVIDE( __Clicks,__Views)
RETURN
__Result
Result:
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
It worked just fine. Thank you!
Just so i can remember this later on, how does it work?
Here are the steps, broken down based on the provided DAX code:
Get Module Name:
Store the selected module name from the column "module name" in a variable named __Module.
Calculate Total Clicks:
Sum up the values in the "clicks" column of Table24 and store the result in a variable named __Clicks.
Calculate Total Views for Screen Events:
Calculate the sum of "views" in Table24 but only for the selected module and events of type "screen".
Store this result in a variable named __Views.
Calculate Click-Through Rate (CTR):
Divide the total clicks (__Clicks) by the total views for screen events (__Views) and store the result in a variable named __Result.
Return the CTR:
Return the calculated CTR (__Result) as the final result of the measure.
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@tone_radeu , You can create a measure for that
CTR =
DIVIDE(
YourTable[clicks],
CALCULATE(
SUM(YourTable[clicks]),
FILTER(
YourTable,
YourTable[module name] = EARLIER(YourTable[module name])
)
),
0
)
Please accept as solution and give kudos if it helps
Proud to be a Super User! |
|
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 84 | |
| 49 | |
| 38 | |
| 31 | |
| 30 |