+ Reply to Thread
Results 1 to 5 of 5

CALCULATE in measure spilling down

  1. #1
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    CALCULATE in measure spilling down

    Hi,
    I have created two measure which I thought would work the same, (DEF; table name);

    < CALCULATE(SUMX(DEF,DEF[Unit]*DEF[Value]),DEF[Area]="A")>


    < SUMX(FILTER(DEF,DEF[Area]="A"),DEF[Unit]*DEF[Value])>

    They both give the same result as a measure but when dropped into the pivot table the CALCULATE sometimes spills down, I seems to be dependent
    on the order entered. Is there a reason for this or is just 'one of those things' , not a major problem just curious.

    Richard.
    Attached Files Attached Files

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: CALCULATE in measure spilling down

    Filter context is the keyword.
    Filter https://www.sqlbi.com/articles/row-c...ontext-in-dax/


    =CALCULATE(SUM([Unit x Value]),DEF[Area]="A")

    CALCULATE force filter to get only Area="A" on every row.
    Filter context doesn't apply to this Measure as Calculate filter overwrite filter to Area="A"



    =SUMX(FILTER(DEF,DEF[Area]="A"),DEF[Unit x Value])
    FILTER(DEF,DEF[Area]="A") -> Filter Area="A" to table, Table only has Area A data

    Area Value Unit
    A 34 10
    A 34 9


    Filter context on each row filter Table that only has "A" for Area

    For Area than is not "A", Table doesn't have any data, SUM of null data show null

  3. #3
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    Re: CALCULATE in measure spilling down

    Hi Bo ry

    This is probably why I'm still more comfortable with calculated columns , I've read through the article,
    I'm still a bit confused by row and filter context, I thought the CALCULATE would enforce row context and where the
    the CALCULATE filer was not true there would be null value.
    To add to this I've attached an workbook show that measure it can work without the spill down? column name calc. I've also put the >=< sumx (filter > along side for comparison.

    Look forward to hearing form you.

    RD
    Attached Files Attached Files

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: CALCULATE in measure spilling down

    5# from https://dax.guide/calculate/

    CALCULATE filter takes over Filter Context if there is any conflict.

    =CALCULATE(SUM([Unit x Value]),DEF[Area]="A")
    All filter context is chang to [Area]="A"

    only 1 filter here [Area]="A"


    =SUMX(FILTER(DEF,DEF[Area]="A"),DEF[Unit]*DEF[Value])

    This is SUMX calculated on FILTER Table that only has [Area]="A".

    Area Value Unit
    A 34 10
    A 34 9

    1st filter on table [Area]="A"


    Then 2nd filter from Filter context A, B , C ,D

    B, C , D doesn't has any data, value show as null

  5. #5
    Forum Contributor
    Join Date
    08-03-2021
    Location
    London
    MS-Off Ver
    365
    Posts
    610

    Re: CALCULATE in measure spilling down

    Hi there,
    thanks for the help in explaining, I'll mark this as closed unless you have any further reading suggestions.

    RD

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 11-17-2021, 12:42 PM
  2. [SOLVED] Measure Calculate YTD versus Last YTD
    By EFA10 in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 08-19-2020, 10:20 AM
  3. Pivot Table: Grand Total different measure from Column measure
    By chinneywow in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 08-07-2019, 06:22 AM
  4. [SOLVED] Help Needed with Power Pivot Calculate Measure
    By rv02 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 05-13-2015, 10:09 AM
  5. Calculate issue accross two differetn tables in a measure
    By concatch in forum PowerPoint Formatting & General
    Replies: 0
    Last Post: 04-24-2013, 09:28 AM
  6. Formula to calculate measure change in numbers
    By drdrez in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 11-30-2009, 02:01 AM
  7. How do I calculate the statistical measure known as omega?
    By macrohunter in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 03-13-2006, 11:10 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1