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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.