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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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