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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
reynold522
Helper II
Helper II

a measure or column calculated base on multiple condition

Hi all, 

 

I have a table like following

 

Battery Type SetupCapacityThreshold Capacity
1110080%*Capacity
217030%*Capacity
3110010%*capacity
1270200%*capacity
22100120%*capacity

 

the column 1-3 are already exist, the forth column is the one that I would like to implement

the value calculated in forth coloumn will be depended on column 1-3, if condition.

 

what will be DAX code for this case?

I would like to use threshold to set alert, is column or measure better for this case?

 

Thanks in advance

 

1 ACCEPTED SOLUTION

Hi @reynold522 ,

 

I suggest you to create a 'Threshold' table and then calculate based on it.

RicoZhou_0-1672215363325.png

Create a calculated column in your capacity table.

Threshold Capacity = 
VAR _Threshold =
    CALCULATE (
        SUM ( Threshold[Threshold] ),
        FILTER (
            Threshold,
            Threshold[Battery Type ] = EARLIER ( 'Table'[Battery Type ] )
                && Threshold[Setup] = EARLIER ( 'Table'[Setup] )
        )
    )
RETURN
    'Table'[Capacity] * _Threshold

 Result is as below.

RicoZhou_1-1672215427147.png

Best Regards,
Rico Zhou

 

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

3 REPLIES 3
FreemanZ
Super User
Super User

hi @reynold522 

 

the pattern is not that obvious. could you explain the logic behind?

Yeah, the threshold (unit capacity) is heavily depend on battery nominal capacity and type of battery as well as battery setup.  

 

e.g., 1st row, if battery type is 1, setup is 1 and capacity is 100, then threshold according to our experimental results should set as 80%*capacity, in this row, capacity is 100, then the value should be 80

Hi @reynold522 ,

 

I suggest you to create a 'Threshold' table and then calculate based on it.

RicoZhou_0-1672215363325.png

Create a calculated column in your capacity table.

Threshold Capacity = 
VAR _Threshold =
    CALCULATE (
        SUM ( Threshold[Threshold] ),
        FILTER (
            Threshold,
            Threshold[Battery Type ] = EARLIER ( 'Table'[Battery Type ] )
                && Threshold[Setup] = EARLIER ( 'Table'[Setup] )
        )
    )
RETURN
    'Table'[Capacity] * _Threshold

 Result is as below.

RicoZhou_1-1672215427147.png

Best Regards,
Rico Zhou

 

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

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

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

Top Kudoed Authors