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
dimk23
Frequent Visitor

Retrieve values of rows from different criteria of column

Hello valuable supporters,

a little boost please because i stacked in DAX 🙂 ,

the final aim is to show up in my Visual (last photo) the values ( cost per kilos) of Depart 1 in rows where belonged to other Departms. The logic behind this is the Depart 1 is the initial phase and doesnt have colours, the colours show up in the following Departs (2,3 etc). For all other departm (2,3 etc) it must be visualised with cost prices of Depart 1. I tried with Filter fuctions (ALL,selectedvalues etc) but something missing because i dont have clear mind for sure 🙂 Any idea please

 

dimk23_1-1657917094747.png

dimk23_1-1657917094747.png

Table Costing

dimk23_2-1657917209612.png

Products

dimk23_3-1657917257182.png

Departments

dimk23_4-1657917290338.png

Visual

dimk23_0-1657917040656.png

 

 

 

 

 

2 ACCEPTED SOLUTIONS
v-cazheng-msft
Community Support
Community Support

Hi @dimk23,

 

You may try this Measure.

CostVal =
VAR InitialCost =
    CALCULATE (
        MIN ( 'Table Costing'[cost] ),
        FILTER (
            ALLEXCEPT ( 'Table Costing', 'Table Costing'[Main products] ),
            'Table Costing'[Department] = "Department 1"
        )
    )
VAR sumCost =
    CALCULATE (
        SUM ( 'Table Costing'[cost] ),
        FILTER ( Departments, 'Departments'[Department] = "Department 2" )
    )
RETURN
    IF (
        ISBLANK ( sumCost ),
        IF (
            MAX ( 'Table Costing'[Colour 1] ) <> "X-0000"
                && MAX ( 'Table Costing'[Colour 2] ) <> "X-0000"
                && MAX ( Departments[Department] ) = "Department 1",
            InitialCost,
            ""
        ),
        sumCost
    )

 

The result looks like this.

vcazhengmsft_0-1658230756787.png

 

Also, attached the pbix file.

 

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 let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

Thanks v-cazheng-msft. Thats perfect 

 
 
 

View solution in original post

6 REPLIES 6
v-cazheng-msft
Community Support
Community Support

Hi @dimk23,

 

You may try this Measure.

CostVal =
VAR InitialCost =
    CALCULATE (
        MIN ( 'Table Costing'[cost] ),
        FILTER (
            ALLEXCEPT ( 'Table Costing', 'Table Costing'[Main products] ),
            'Table Costing'[Department] = "Department 1"
        )
    )
VAR sumCost =
    CALCULATE (
        SUM ( 'Table Costing'[cost] ),
        FILTER ( Departments, 'Departments'[Department] = "Department 2" )
    )
RETURN
    IF (
        ISBLANK ( sumCost ),
        IF (
            MAX ( 'Table Costing'[Colour 1] ) <> "X-0000"
                && MAX ( 'Table Costing'[Colour 2] ) <> "X-0000"
                && MAX ( Departments[Department] ) = "Department 1",
            InitialCost,
            ""
        ),
        sumCost
    )

 

The result looks like this.

vcazhengmsft_0-1658230756787.png

 

Also, attached the pbix file.

 

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 let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

Thanks v-cazheng-msft. Thats perfect 

 
 
 
dimk23
Frequent Visitor

If you deduct the MAX of for colors 1 and 2 would be exactly that i wanted in my report. thank you again for you time.

___RETURNIF (ISBLANK ( sumCost ),IF (MAX ( Departments[Department] ) = "Department 1",InitialCost,""),sumCost)

dimk23_0-1658245035692.png

 

dimk23
Frequent Visitor

The color 1 and 2 means that, the product had painted with two colors and may with one color (the X-0000 means no color as you mentioned)  in Departm 2. I dont wont to feel with other color, i want to show up the cost value from the earliest Departm 1.

vapid128
Solution Specialist
Solution Specialist

image.png

add colnum

Color 1 Initial = "x-0000"

Color 2 Initial = "x-0000"

vapid128
Solution Specialist
Solution Specialist

When a product get both color 1 and color 2 x-0000 means no color.

The product with no color need a color from other line with same name of product name.

 

If every product with same name has same color 1/ color 2 and the name all like x-4 digits numbers, there is a easy way to make it work.

 

add colnum 

color 1 new = calculate(max([Color 1], ALLEXCEPT([Main Product]))

color 2 new = calculate(max([Color 2], ALLEXCEPT([Main Product]))

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.