Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have 2 Tables
Problem:
I need to calculate Fair Share Index (share of product in a region/ share of its cat in the same region), which is essentially division of ratios. The first part will have the Product Sales(Dollar Sales) in a Geography for a Time Period divided by Product Sales at National level from Table 1. The second part will have the Category Sales (Cat Dollar Sales) in the same Geography for same Time Period divided by Category Sales at the National Level from Table 2
I need a new Measure in Table 1 with this formula:
For each row: Index = [ (Table 1 row[Dollar Sales] / Table 1 [Dollar Sales] where [Geography] == "National" & [Time] == row[Time] & [Prod] = row[Prod]) / (Table 2 row [Cat Dollar Sales] / Table 2 [Cat Dollar Sales] where Geography == "National") ] * 100
Example:
Consider the Bold and Italicized Row in above Table 1. The calculation will be as follows,
Fair Share Index = [ (100/500) / (1000/10000)) ] * 100
= [ (0.2) / (0.1) ] * 100
= 200%
What I have Tried:
I have joined the Tables in the Data Model on Product Column with Many to Many cardinality and Table 1 filters Table 2.
I have tried implementing several type of DAX queries but everything throws an error. I'm new to PowerBI especially DAX. I have done the same in Python with no issues. So any pointers on how I can achieve this would be greatly appreciated. Thanks in advance
Solved! Go to Solution.
Hi @Logesshwar
You can create a calculated column in table 1 with below DAX:
Column =
VAR a =
DIVIDE (
CALCULATE ( SUM ( 'Table 1'[Dollar Sales] ) ),
SUMX (
FILTER (
ALL ( 'Table 1' ),
'Table 1'[Product] = EARLIER ( 'Table 1'[Product] )
&& 'Table 1'[Time] = EARLIER ( 'Table 1'[Time] )
&& 'Table 1'[Geography] = "National"
),
'Table 1'[Dollar Sales]
)
)
VAR b =
DIVIDE (
CALCULATE (
SUM ( 'Table 2'[Cat Dollor Sales] ),
'Table 2'[Product] = EARLIER ( 'Table 1'[Product] )
&& 'Table 2'[Geography] = EARLIER ( 'Table 1'[Geography] )
&& 'Table 2'[Time] = EARLIER ( 'Table 1'[Time] )
),
CALCULATE (
SUM ( 'Table 2'[Cat Dollor Sales] ),
'Table 2'[Product] = EARLIER ( 'Table 1'[Product] )
&& 'Table 2'[Geography] = "National"
&& 'Table 2'[Time] = EARLIER ( 'Table 1'[Time] )
)
)
RETURN
DIVIDE ( a, b )
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi @Logesshwar
You can create a calculated column in table 1 with below DAX:
Column =
VAR a =
DIVIDE (
CALCULATE ( SUM ( 'Table 1'[Dollar Sales] ) ),
SUMX (
FILTER (
ALL ( 'Table 1' ),
'Table 1'[Product] = EARLIER ( 'Table 1'[Product] )
&& 'Table 1'[Time] = EARLIER ( 'Table 1'[Time] )
&& 'Table 1'[Geography] = "National"
),
'Table 1'[Dollar Sales]
)
)
VAR b =
DIVIDE (
CALCULATE (
SUM ( 'Table 2'[Cat Dollor Sales] ),
'Table 2'[Product] = EARLIER ( 'Table 1'[Product] )
&& 'Table 2'[Geography] = EARLIER ( 'Table 1'[Geography] )
&& 'Table 2'[Time] = EARLIER ( 'Table 1'[Time] )
),
CALCULATE (
SUM ( 'Table 2'[Cat Dollor Sales] ),
'Table 2'[Product] = EARLIER ( 'Table 1'[Product] )
&& 'Table 2'[Geography] = "National"
&& 'Table 2'[Time] = EARLIER ( 'Table 1'[Time] )
)
)
RETURN
DIVIDE ( a, b )
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
8 |
User | Count |
---|---|
13 | |
12 | |
11 | |
10 | |
8 |