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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. 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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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