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
Julia2023
Helper I
Helper I

Ideas for Measure

Hi everyone, I'm looking for some ideas. I have a measure called "Position," and I need to create a measure called "GOAL" (which should be the sum of "Position" but with a total of 100%). The current approach I tried involves adding the Product ID level, which is causing heavy loading and resulting in an error: "The operation was canceled due to locking conflicts."

Julia2023_1-1730963363735.png

 

Position = 

VAR TotalRev = 
    CALCULATE(
        [revenue],
        REMOVEFILTERS(ID[Product ID])
    )

VAR Result = 
    DIVIDE([revenue], TotalRev, 0)

RETURN
    Result
GOAL = 
VAR IDSales = [Position]

RETURN
    IF(
        ISBLANK(IDSales),
        BLANK(),
        VAR Table = 
            ADDCOLUMNS(
                ALL(ID[Product ID]),
                "@Position",
                [Position]
            )
        
        VAR FilteredTable = 
            FILTER(
               Table,
                [@Position] >= IDSales
            )
        
        VAR Result = 
            SUMX(
                FilteredTable,
                [@Position]
            )

        RETURN
            Result
    )

 




4 REPLIES 4
v-heq-msft
Community Support
Community Support

Hi @Julia2023 ,
You can calculate the total sum of the "Position" measure. And then Divide each "Position" value by the total sum to get the percentage.

TotalPosition = 
    CALCULATE(
        SUM('YourTable'[Position]),
        REMOVEFILTERS('YourTable')
    )
GOAL = 
DIVIDE(
    SUM('YourTable'[Position]),
    TotalPosition,
    0
)

 

Best regards,
Albert He


If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

shafiz_p
Super User
Super User

Hi @Julia2023  What I understood about your Goal measure in your provided image, that it is calculating cumulative sum of position based on product ID.

If this is the case, then you should rank your position decending order and evaluate cumulative sum. You can try below 2 measure.

Rank Measure:

ProductKeyRank = 
RANKX(
    ALLSELECTED(DimProduct[ProductKey]),
    [Position],
    ,
    DESC,
    DENSE
)

 

We will filter product table based on this rank and feed this table to calculate function to sum up position to construct 100%.

Goal Measure:

Goal = 
VAR CurrentRank = [ProductKeyRank]

RETURN
CALCULATE(
    [Position],
    FILTER(
        ALLSELECTED(DimProduct[ProductKey]),
        [ProductKeyRank] <= CurrentRank
    )
)

 

Change column name according to your table column name. You could rank any dimension based on this technique and conduct cumulative sum.

 

Here is the output of my goal measure:

shafiz_p_0-1730967235602.png

You can avoid total level by using inscope or hasonevalue function.

Hope this helps!!

If this solved your problem, please accept it as a solution and a kudos!!

 

 

Best Regards,
Shahariar Hafiz

 

Thank you for the idea. It works when using a filter, but without any filter, loading and nothing... maybe it's because have more than 180k product IDs

danextian
Super User
Super User

Hi @Julia2023 

 

This measure below creates  a virtual summary table by product id containing a column called @position which returns a value if [goal] is equal to 1.

SUMX (
    ADDCOLUMNS (
        SUMMARIZE ( 'table', 'table'[product id] ),
        "@position", IF ( [goal] = 1, [position] )
    ),
    [@position]
)

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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!

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.