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
FelipMark
Helper II
Helper II

Measure in DAX to represent sales in the customer's state

Hi everyone, I have a problem.

I have the following database:

FelipMark_0-1683337846887.png

 

I want to create a measure that returns the % of sales of each customer within their state but I don't know how. Can anyone help me??

1 ACCEPTED SOLUTION

hi @FelipMark 

just noticed you expected a measure, try like:

measure = 
DIVIDE(
    SUM(data[SALE]),    
    SUMX(
        FILTER(
            ALL(data),
            data[State]=MAX(data[State])
        ),
        data[Sale]
    )
)

it worked like:

FreemanZ_0-1683343269967.png

View solution in original post

4 REPLIES 4
FreemanZ
Super User
Super User

hi @FelipMark 

try to add a calculated column like:

Column = 
DIVIDE(
    [SALE],    
    SUMX(
        FILTER(
            data,
            data[State]=EARLIER(data[State])
        ),
        data[Sale]
    )
)

it worked like:

FreemanZ_0-1683339212031.png

Is that so?

not working, the error says the following:
EARLIER/EARLIEST references a previous row context that does not exist.

FelipMark_0-1683341720948.png

 

 

hi @FelipMark 

just noticed you expected a measure, try like:

measure = 
DIVIDE(
    SUM(data[SALE]),    
    SUMX(
        FILTER(
            ALL(data),
            data[State]=MAX(data[State])
        ),
        data[Sale]
    )
)

it worked like:

FreemanZ_0-1683343269967.png

It worked! Thanks

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!

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.