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.
Hello everyone,
I have been breaking my head on this for the last 48 hours! and finally I seek help..!
Lets say I have the following dataset:
Region | Country | Category | Device | Pageviews |
West | US | Category A | desktop | 999 |
West | US | Category A | mobile | 100 |
West | US | Category A | tablet | 999 |
West | US | Category B | desktop | 1499 |
West | US | Category B | mobile | 1355 |
West | US | Category B | tablet | 678 |
West | US | Category C | desktop | 1200 |
West | US | Category C | mobile | 708 |
West | US | Category C | tablet | 167 |
Europe | GB | Category A | desktop | 1500 |
Europe | GB | Category A | mobile | 320 |
Europe | GB | Category A | tablet | 195 |
Europe | GB | Category B | desktop | 536 |
Europe | GB | Category B | mobile | 16 |
Europe | GB | Category B | tablet | 25 |
Europe | GB | Category C | desktop | 1600 |
Europe | GB | Category C | mobile | 357 |
Europe | GB | Category C | tablet | 990 |
… | … | … | … | … |
On my report I have 2 visual filters: 1 for Category and another for say country.
I need to display the value for whats the desktop share, mobile share and tablet share (and the measures should adjust dynamically based on the filter selection!)
What I did so far:
Created measure for desktop share:
Desktop Share =
VAR Selection = IF (
ISFILTERED ( 'Table'[Category]),
FILTERS ('Table'[Category]),""
) RETURN
CALCULATE(IF (Selection = "",
CALCULATE (
SUM('Table'[Pageviews]),
ALL ('Table'),
FILTER ('Table', TRIM('Table'[Device]) = "desktop")
) /
CALCULATE (
SUM('Table'[Pageviews]),
ALL ('Table')
),
CALCULATE (
SUM('Table'[Pageviews]),
ALL ('Table'),
FILTER ('Table', TRIM('Table'[Device]) = "desktop" && TRIM('Table'[Category]) = Selection)
) /
CALCULATE (
SUM('Table'[Pageviews]),
ALL ('Table'),
FILTER ('Table', TRIM('Table'[Category]) = Selection)
)))
This works OK if I would have had just 1 filter. As I want multiple filters I feel confused what would be the way to do this?
Any help would be really appreciated. Please let me know if you would like me to elaborate more on my question!
Solved! Go to Solution.
Try this MEASURE
Market Share = DIVIDE ( SUM ( 'Table'[Pageviews] ), CALCULATE ( SUM ( 'Table'[Pageviews] ), ALLSELECTED ( 'Table' ) ) )
Try this MEASURE
Market Share = DIVIDE ( SUM ( 'Table'[Pageviews] ), CALCULATE ( SUM ( 'Table'[Pageviews] ), ALLSELECTED ( 'Table' ) ) )
Thank you very much! I see how, ALLSELECTED helps!
I did the following and it worked like a charm for me....
Desktop Share2 =
DIVIDE (
CALCULATE (
SUM('Table'[Pageviews]),
ALL ('Table'),
FILTER ('Table', TRIM('Table'[Device]) = "desktop")
),
CALCULATE (SUM('Table'[Pageviews]), ALLSELECTED ('Table'))
)
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 |
---|---|
110 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
148 | |
111 | |
94 | |
84 | |
67 |