Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
BogdanRak
Regular Visitor

Sum Rows in Fact Table

Hi,

 

Please, advise how to create measure and build Matrix (PivotTable)

I have fact table

Week_IDEmployee_IDProduct_IDCallsDistribution
11NULL10NULL
21NULL10NULL
31NULL10NULL
111NULL5
112NULL7
113NULL3
211NULL7
212NULL8
213NULL9
311NULL5
312NULL5
313NULL5
12NULL20NULL
22NULL20NULL
32NULL20NULL
121NULL5
122NULL7
123NULL3
221NULL7
222NULL8
223NULL9
321NULL5
322NULL5
323NULL5

 

And want to recieve such Pivot:

  Product  
WeekEmployee123
11SUM(Distribution)/SUM(Calls)
21   
31   
12   
22   
32   
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @BogdanRak ,

Here are the steps you can follow:

1. Open the Matrix visual. – Row headers – options – stepped layout.

vyangliumsft_0-1659664190409.png

2. Create measure.

SUM(Distribution)/SUM(Calls) if divided by

0 becomes 0 whether it is divided by or divided by a number

Measure 2 =
var _1=
SUMX(FILTER(ALL('Table'),
'Table'[Week_ID]=MAX('Table'[Week_ID])&&'Table'[Employee_ID]=MAX('Table'[Employee_ID])&&'Table'[Product_ID]=
MAX('Table'[Product_ID])),[Distribution])
var _2=
SUMX(FILTER(ALL('Table'),
'Table'[Week_ID]=MAX('Table'[Week_ID])&&'Table'[Employee_ID]=MAX('Table'[Employee_ID])&&'Table'[Product_ID]=
MAX('Table'[Product_ID])),[Calls])
var _index1=
IF(
    _1=BLANK(),0,_1)
var _index2=
IF(
    _2=BLANK(),0,_2)
return
DIVIDE(
_index1,_index2)

 

vyangliumsft_1-1659664190411.png

SUM(Distribution)/SUM(Calls) if it is a concatenated string

Measure =
var _1=
SUMX(FILTER(ALL('Table'),
'Table'[Week_ID]=MAX('Table'[Week_ID])&&'Table'[Employee_ID]=MAX('Table'[Employee_ID])&&'Table'[Product_ID]=
MAX('Table'[Product_ID])),[Distribution])
var _2=
SUMX(FILTER(ALL('Table'),
'Table'[Week_ID]=MAX('Table'[Week_ID])&&'Table'[Employee_ID]=MAX('Table'[Employee_ID])&&'Table'[Product_ID]=
MAX('Table'[Product_ID])),[Calls])
var _index1=
IF(
    _1=BLANK(),0,_1)
var _index2=
IF(
    _2=BLANK(),0,_2)
return
_index1&"/"&_index2

vyangliumsft_2-1659664190412.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

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

1 REPLY 1
Anonymous
Not applicable

Hi  @BogdanRak ,

Here are the steps you can follow:

1. Open the Matrix visual. – Row headers – options – stepped layout.

vyangliumsft_0-1659664190409.png

2. Create measure.

SUM(Distribution)/SUM(Calls) if divided by

0 becomes 0 whether it is divided by or divided by a number

Measure 2 =
var _1=
SUMX(FILTER(ALL('Table'),
'Table'[Week_ID]=MAX('Table'[Week_ID])&&'Table'[Employee_ID]=MAX('Table'[Employee_ID])&&'Table'[Product_ID]=
MAX('Table'[Product_ID])),[Distribution])
var _2=
SUMX(FILTER(ALL('Table'),
'Table'[Week_ID]=MAX('Table'[Week_ID])&&'Table'[Employee_ID]=MAX('Table'[Employee_ID])&&'Table'[Product_ID]=
MAX('Table'[Product_ID])),[Calls])
var _index1=
IF(
    _1=BLANK(),0,_1)
var _index2=
IF(
    _2=BLANK(),0,_2)
return
DIVIDE(
_index1,_index2)

 

vyangliumsft_1-1659664190411.png

SUM(Distribution)/SUM(Calls) if it is a concatenated string

Measure =
var _1=
SUMX(FILTER(ALL('Table'),
'Table'[Week_ID]=MAX('Table'[Week_ID])&&'Table'[Employee_ID]=MAX('Table'[Employee_ID])&&'Table'[Product_ID]=
MAX('Table'[Product_ID])),[Distribution])
var _2=
SUMX(FILTER(ALL('Table'),
'Table'[Week_ID]=MAX('Table'[Week_ID])&&'Table'[Employee_ID]=MAX('Table'[Employee_ID])&&'Table'[Product_ID]=
MAX('Table'[Product_ID])),[Calls])
var _index1=
IF(
    _1=BLANK(),0,_1)
var _index2=
IF(
    _2=BLANK(),0,_2)
return
_index1&"/"&_index2

vyangliumsft_2-1659664190412.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors