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
Anonymous
Not applicable

measure incorrectly repeating values for matrix visual

I have a simple data model:

table: 'Dimension Project'

table: 'Dimension Employee Weekly Schedule'

table: 'Fact Sales'

 

I have a matrix visual with Rows:

'Dimension Project'[Proj ID]

    'Dimension Employee Weekly Schedule'[Employee ID]

 

For the Values, I want to include a measure that sums sales for the last 4 weeks.  However, on the page, there is a filter being applied that limits the timespan to the next 4 weeks (for other purposes).  So, I have implemented:

Sum of Sales - last 4 weeks =

CALCULATE(
    SUM('Fact Sales'[Amount])

    ,ALL('Dimension Employee Schedule')
    ,'Dimension Project'[Type] = "A"
    ,'Dimension Employee Schedule'[Week Number] IN {-1, -2, -3, -4}
)

 

This measure is returning the correct values at the 'Dimension Project'[Proj ID] level and the Total level.  However, it is repeating the value from the 'Dimension Project'[Proj ID] level when expanding into the 'Dimension Employee Weekly Schedule'[Employee ID] level.  This is incorrect behavior.  How can I correct this behavior?

 

For reference, I have tried the following, which no longer repeats the value down to the employee level.  But, now all employees are being returned per project, instead of only the ones that have a row in the 'Fact Sales' table for the given project.

CALCULATE(
    SUM('Fact Sales'[Amount])

    ,ALLEXCEPT(

        'Dimension Employee Schedule'

        ,'Dimension Employee Schedule'[Employee ID]

    )
    ,'Dimension Project'[Type] = "A"
    ,'Dimension Employee Schedule'[Week Number] IN {-1, -2, -3, -4}
)

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@amitchandak 

My problem isn't the filtering to the proper weeks.  My problem is that the measure value at the project level was repeating down to the employee level.  (As a minor note, my "employee" dimension table also serves as a "week" dimension table.  This is necessary because employee information is time-variant, e.g., an employee's weekly work hours changes by week because of holidays.)

 

However, it turns out that the second measure definition that I posted actually does give me the behavior that I want.  So, no help is needed after all.  Again, this measure is:

CALCULATE(
    SUM('Fact Sales'[Amount])

    ,ALLEXCEPT(

        'Dimension Employee Schedule'

        ,'Dimension Employee Schedule'[Employee ID]

    )
    ,'Dimension Project'[Type] = "A"
    ,'Dimension Employee Schedule'[Week Number] IN {-1, -2, -3, -4}
)

 

In testing, it turns out that another measure (not the measure above) on my matrix visual was forcing all employees to return for each project.  The measure definition above wasn't causing it.

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , For the week, Create a week Rank in your week table and then try measure like. Week /date should be a separate table

 

Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)
This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))
Last year Week= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))
Last 4 weeks = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]>=max('Date'[Week Rank])-4 && 'Date'[Week Rank]<=max('Date'[Week Rank])))

 

As this might group data in one week, Refer this approch

https://www.youtube.com/watch?v=duMSovyosXE

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

@amitchandak 

My problem isn't the filtering to the proper weeks.  My problem is that the measure value at the project level was repeating down to the employee level.  (As a minor note, my "employee" dimension table also serves as a "week" dimension table.  This is necessary because employee information is time-variant, e.g., an employee's weekly work hours changes by week because of holidays.)

 

However, it turns out that the second measure definition that I posted actually does give me the behavior that I want.  So, no help is needed after all.  Again, this measure is:

CALCULATE(
    SUM('Fact Sales'[Amount])

    ,ALLEXCEPT(

        'Dimension Employee Schedule'

        ,'Dimension Employee Schedule'[Employee ID]

    )
    ,'Dimension Project'[Type] = "A"
    ,'Dimension Employee Schedule'[Week Number] IN {-1, -2, -3, -4}
)

 

In testing, it turns out that another measure (not the measure above) on my matrix visual was forcing all employees to return for each project.  The measure definition above wasn't causing it.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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