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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
JuicyJ35
Frequent Visitor

Calculated Column based off conditions

My work has a new Ecommerce system and our sales enter our POS in a different format. Normally our online sales come from the store they are purchased and picked up from, but now the purchase has Ecommerce as the store and it adds an extra $0 product to the purchase and it is named as the store. For our reporting this is an issue because it still shows inventory leaving that store, but it doesn't track it as sales for that store. Here is examples of what a few sales look like.

 

Store         Quantity  Revenue   Product Name    SaleID

Ecommerce    1              $0            Store A            06543

Ecommerce    1              $5           Product B         06543

 

And here is what a normal sale from our store looks like

 

Store         Quantity  Revenue   Product Name    SaleID
Store C            1             $4            Product D       REG-100
 

I'm thinking of creating a calculated column in PowerBI showing if Store = 'Ecommerce', and if Sale ID is equal, and if Revenue = $0, then show Product Name (which would be the Store). But I can't seem to format it right. I know it can be done I'm just a little stuck. If anyone could give me a hand I would appreciate it.

 

Here is what I want the calculated column to display.

 

Store         Quantity  Revenue   Product Name    SaleID   Ecom Store

Ecommerce    1              $0            Store A            06543      Store A

Ecommerce    1              $5           Product B         06543      Store A

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @JuicyJ35 ,

Please try to create a new column with below dax formula:

Column =
VAR tmp =
    FILTER ( 'Table', [Store] = "Ecommerce" && [Revenue] = 0 )
VAR _a =
    CALCULATE ( MAX ( 'Table'[Store] ), tmp )
VAR _b =
    CALCULATE ( MAX ( 'Table'[SaleID] ), tmp )
VAR _c =
    CALCULATE ( MAX ( 'Table'[Product Name] ), tmp )
VAR cur_store = [Store]
VAR cur_saleid = [SaleID]
RETURN
    IF ( cur_store = "Ecommerce" && cur_saleid = _b, _c )

vbinbinyumsft_0-1698374648153.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
JuicyJ35
Frequent Visitor

Hello, unfortunetly this didn't work for me. 

 

JuicyJ35_1-1698856553909.png

 

 

JuicyJ35_0-1698856527427.png

 

Anonymous
Not applicable

Hi @JuicyJ35 ,

Please try to create a new column with below dax formula:

Column =
VAR tmp =
    FILTER ( 'Table', [Store] = "Ecommerce" && [Revenue] = 0 )
VAR _a =
    CALCULATE ( MAX ( 'Table'[Store] ), tmp )
VAR _b =
    CALCULATE ( MAX ( 'Table'[SaleID] ), tmp )
VAR _c =
    CALCULATE ( MAX ( 'Table'[Product Name] ), tmp )
VAR cur_store = [Store]
VAR cur_saleid = [SaleID]
RETURN
    IF ( cur_store = "Ecommerce" && cur_saleid = _b, _c )

vbinbinyumsft_0-1698374648153.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

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.