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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
RYRY
New Member

Calculate final overall value for new column based on my custom order of another calculated column

Hi 

I am trying to work out how to get a final value based on a hierarchy/custom order (I have added a number for simplicity alpha-numeric ordering) from another column. Some records may only have one row per customer_id so they aren't an issue, but some other customer records may have multiple rows. Each of those row can have a different outcome value. 

 

I have used the RANKX function unsuccessfully at this stage but I may be using the incorrect terminolgy here. 

 

Here is what I would like to occur (thanks in advance!)

Customer_IDIndividual_State (NB this column is calculated)**Expected column** Overall_State
abc1. ShippedSHIPPED
cde

1. Shipped

SHIPPED
cde2. PaidSHIPPED

efg

3. OrderedORDERED
efg4. CheckedORDERED
efg4. CheckedORDERED
hij5. ConfirmedPAID
hij2. PaidPAID
1 ACCEPTED SOLUTION
v-huijiey-msft
Community Support
Community Support

Hi @RYRY,

 

Please follow these steps:

  1. Use CALCULATE() to group by Customer_ID and then take the minimum value.
  2. Use RIGHT(), based on "." Take the right half of the separation and then turn capitalization to get the results you want.

The DAX expression for the calculated column is as follows:

 

Overall_State = 
VAR _last_value = CALCULATE(MIN('Table'[Individual_State]),ALLEXCEPT('Table','Table'[Customer_ID]))
VAR _result = RIGHT(_last_value,LEN(_last_value)-SEARCH(".",'Table'[Individual_State]))
RETURN
UPPER(_result)

 

Result:

vhuijieymsft_0-1704183402990.png

 

Best Regards,
Yang
Community Support Team

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

View solution in original post

3 REPLIES 3
v-huijiey-msft
Community Support
Community Support

Hi @RYRY,

 

Please follow these steps:

  1. Use CALCULATE() to group by Customer_ID and then take the minimum value.
  2. Use RIGHT(), based on "." Take the right half of the separation and then turn capitalization to get the results you want.

The DAX expression for the calculated column is as follows:

 

Overall_State = 
VAR _last_value = CALCULATE(MIN('Table'[Individual_State]),ALLEXCEPT('Table','Table'[Customer_ID]))
VAR _result = RIGHT(_last_value,LEN(_last_value)-SEARCH(".",'Table'[Individual_State]))
RETURN
UPPER(_result)

 

Result:

vhuijieymsft_0-1704183402990.png

 

Best Regards,
Yang
Community Support Team

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

Awesome! So simple but I need to learn the 'ALLEXCEPT' function a bit more.

Cheers

Fowmy
Super User
Super User

@RYRY 

First, create atable to store the Status and Sequence Order

Fowmy_0-1704178432616.png

 

Fowmy_1-1704178447167.png


Add the following calculated column:

Overall State = 
VAR __Order = 
    MINX(
    ADDCOLUMNS(
        CALCULATETABLE( VALUES( Table02[Individual_State] ) , ALLEXCEPT( Table02 , Table02[Customer_ID] )),
        "Order" , LOOKUPVALUE( OrderStatus[Order] , OrderStatus[Status], Table02[Individual_State] )
    ),
    [Order]
    )
VAR __Result =  LOOKUPVALUE( OrderStatus[Status] , OrderStatus[Order], __Order )
RETURN
    __Result

Fowmy_2-1704178488174.png

 





 

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.