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
marsclone
Helper IV
Helper IV

IF Function

I'm struggling with (i think) an easy measure.

But can't get it to work.

 

I have an open item list from my customers.

I have a list with max limits for my customers.

 

I want to create a matrix which shows the total amount per customer and if the total amount exceeds the limit it must show the shortfall of this position.

Open item list
CustomerInvoiceAmount
A201901€ 250
A201902€ 350
B201903€ 600
B201904€ 400
B201905€ 200
C201906€ 390
C201907€ 250
C201908€ 600
C201909€ 800
   
  € 3.840

 

Limitlist
CustomerLimit
A€ 800
B€ 1.000
C

€ 2.000

 

Total list
CustomerAmountLimitShortfall
A6008000
B12001000-200
C20402000-40
    
 3840 -240
    

 

 

Which measure do i need for this?

 

Thank you in advance

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@marsclone 

 

Try this MEASURE

see attached file as well

 

Measure =
IF (
    HASONEFILTER ( LimitList[Customer] ),
    IF (
        SUM ( Open_item_list[Amount] ) > SUM ( LimitList[Limit] ),
        SUM ( LimitList[Limit] ) - SUM ( Open_item_list[Amount] ),
        0
    ),
    SUMX (
        VALUES ( LimitList[Customer] ),
        CALCULATE (
            IF (
                SUM ( Open_item_list[Amount] ) > SUM ( LimitList[Limit] ),
                SUM ( LimitList[Limit] ) - SUM ( Open_item_list[Amount] ),
                0
            )
        )
    )
)

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@marsclone 

 

Try this MEASURE

see attached file as well

 

Measure =
IF (
    HASONEFILTER ( LimitList[Customer] ),
    IF (
        SUM ( Open_item_list[Amount] ) > SUM ( LimitList[Limit] ),
        SUM ( LimitList[Limit] ) - SUM ( Open_item_list[Amount] ),
        0
    ),
    SUMX (
        VALUES ( LimitList[Customer] ),
        CALCULATE (
            IF (
                SUM ( Open_item_list[Amount] ) > SUM ( LimitList[Limit] ),
                SUM ( LimitList[Limit] ) - SUM ( Open_item_list[Amount] ),
                0
            )
        )
    )
)

That worked really well!

 

So it must be in table form and not matrix?

 

Thank you!

 

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

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