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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
tomislav_mi
Helper II
Helper II

filter

 
3 REPLIES 3
Anonymous
Not applicable

I don't understand how these percentages are created from the row numbers. Would you please expand on this?

Thanks.

Best
D

I assume that it is this part of the code which is confusing:

SUMX (
  VALUES ( 'Table'[Month] ),
  VAR _mo = CALCULATE ( SELECTEDVALUE ( 'Table'[Month] ) )
  RETURN
  CALCULATE (
    SUM ( 'Table'[value] ),
      FILTER ( ALL ( 'Table' ), 'Table'[Month] = _mo && 'Table'[cohort] = 1 )
    )
  )
)

 

The SUMX-function is an iterator. It will perform an operation for each row of the table argument it is given. The syntax is SUMX(Table,Expression). In the code above, VALUES(Table[Month]) is the table argument, as the VALUES-function returns a 1 column table. Then there is a variable, _mo which refers to the Table[month] currently iterated. Then expression argument of SUMX is given by summing the table filtered by _mo and 'Table'[cohort]=1.

When this measure is evaluated on a row in a e.g. a table visual, VALUES(Table[Month]) will return a table with 1 column and 1 row, so the iterations i strictly not needed. But for the grand total, VALUES(Table[Month]) will return all the Table[Month]-values present in the visual, and iterate over each month, and then sum the values.


The table

sturlaws
Resident Rockstar
Resident Rockstar

Hi @tomislav_mi 

 

see if this measure does the trick:

Measure =
DIVIDE (
    SUM ( 'Table'[value] ),
    SUMX (
        VALUES ( 'Table'[Month] ),
        VAR _mo =
            CALCULATE ( SELECTEDVALUE ( 'Table'[Month] ) )
        RETURN
            CALCULATE (
                SUM ( 'Table'[value] ),
                FILTER ( ALL ( 'Table' ), 'Table'[Month] = _mo && 'Table'[cohort] = 1 )
            )
    )
)

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.