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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors