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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

Multiple IF functions

Hi,

 

I'm very new to DAX functions and have been trying to combine multiple IF criterias, with 2 different data sources. The end result i'm looking for is pipeline data divided by budget by quarter as a value that shows as for example - 2x, 3x, 1.5x etc etc.. 

 

Pipeline X =

 

IF(FILTER(Pipeline,Pipeline[Fiscal Period]="Q1-2017"), sum(Pipeline[Value USD]) / sum('Targets and Actuals New'[Q1 Budget]),
IF(FILTER(Pipeline,Pipeline[Fiscal Period]="Q3-2017"), sum(Pipeline[Value USD]) / sum('Targets and Actuals New'[Q3 Budget]),
IF(FILTER(Pipeline,Pipeline[Fiscal Period]="Q4-2017"), sum(Pipeline[Value USD]) / sum('Targets and Actuals New'[Q4 Budget]),
[Q+2 Qualified Pipeline] / sum ('Targets and Actuals New'[Q2 Budget])))

 

The error I get is - "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."

 

Can someone please help correct this formula?

 

Thanks!

 

 

1 ACCEPTED SOLUTION

@Anonymous

 

I just test with the two tables you provided, they are related with Region. Since you want Q2 to calculate on qualified pipeline, I create a new qualified column which only keeps the actual qualified status for Q2, and other quarters are updated to Y.

 

Qualified_Update =
IF ( SEARCH ( "Q2", Table1[Fiscal Period],, -1 ) > 0, Table1[Qualified], "Y" )

We also need to create a year quarter column.

YearQuarter = 
RIGHT ( Table1[Fiscal Period], 4 ) * 100
    + MID ( Table1[Fiscal Period], 2, 1 )

Then create three measures to get the results shown in excel.

Pipeline_2 = 
VAR YearQuarter =
    CALCULATE ( AVERAGE ( Table1[YearQuarter] ) )
RETURN
    IF (
        CONTAINS ( Table1, Table1[YearQuarter], YearQuarter ),
        CALCULATE (
            SUM ( Table1[USD] ),
            FILTER (
                ALLSELECTED ( Table1 ),
                Table1[YearQuarter] = YearQuarter
                    && Table1[Qualified_Update] = "Y"
            )
        ),
        CALCULATE (
            SUM ( Table1[USD] ),
            FILTER ( ALLSELECTED ( Table1 ), Table1[Qualified_Update] = "Y" )
        )
    )
Budget_2 = 
VAR YearQuarter =
    CALCULATE ( AVERAGE ( Table1[YearQuarter] ) )
VAR Q1Budget =
    CALCULATE ( SUM ( Table2[Q1 Budget] ), ALLSELECTED ( Table1 ) )
VAR Q2Budget =
    CALCULATE ( SUM ( Table2[Q2 Budget] ), ALLSELECTED ( Table1 ) )
VAR Q3Budget =
    CALCULATE ( SUM ( Table2[Q3 Budget] ), ALLSELECTED ( Table1 ) )
VAR Q4Budget =
    CALCULATE ( SUM ( Table2[Q4 Budget] ), ALLSELECTED ( Table1 ) )
RETURN
    SWITCH (
        YearQuarter,
        201701, Q1Budget,
        201702, Q2Budget,
        201703, Q3Budget,
        201704, Q4Budget,
        Q1Budget + Q2Budget
            + Q3Budget
            + Q4Budget
    )
Coverage_2 = 
ROUND ( [Pipeline_2] / [Budget_2], 1 )
& "x"

Multiple IF functions_1.jpg

 

Best Regards,

Herbert

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

Is this a column or a measure? Are the tables related? Can you post some sample data to recreate your data model and test?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

hi @Greg_Deckler,
 
Pipeline - Table
Pipeline[Fiscal Period] - column within above table
Q2 Qualified Pipeline - Measure
 
Yes, tables are related based on the Region, product line and pipeline opportunity owner (owner info not included in sample data).
 
I have attached sample data with two tables (pipeline and budget data) and also the final view that I am looking for.
 
Hope this helps resolve my query. Thanks!

 

PS - I have the sample data in an excel, how do i attach it here. There does;t seem to be any option except to embed a picture 😞

Anonymous
Not applicable

Hi @Greg_Deckler

 

Attaching image!

 

Sample Data.JPG

@Anonymous

 

I just test with the two tables you provided, they are related with Region. Since you want Q2 to calculate on qualified pipeline, I create a new qualified column which only keeps the actual qualified status for Q2, and other quarters are updated to Y.

 

Qualified_Update =
IF ( SEARCH ( "Q2", Table1[Fiscal Period],, -1 ) > 0, Table1[Qualified], "Y" )

We also need to create a year quarter column.

YearQuarter = 
RIGHT ( Table1[Fiscal Period], 4 ) * 100
    + MID ( Table1[Fiscal Period], 2, 1 )

Then create three measures to get the results shown in excel.

Pipeline_2 = 
VAR YearQuarter =
    CALCULATE ( AVERAGE ( Table1[YearQuarter] ) )
RETURN
    IF (
        CONTAINS ( Table1, Table1[YearQuarter], YearQuarter ),
        CALCULATE (
            SUM ( Table1[USD] ),
            FILTER (
                ALLSELECTED ( Table1 ),
                Table1[YearQuarter] = YearQuarter
                    && Table1[Qualified_Update] = "Y"
            )
        ),
        CALCULATE (
            SUM ( Table1[USD] ),
            FILTER ( ALLSELECTED ( Table1 ), Table1[Qualified_Update] = "Y" )
        )
    )
Budget_2 = 
VAR YearQuarter =
    CALCULATE ( AVERAGE ( Table1[YearQuarter] ) )
VAR Q1Budget =
    CALCULATE ( SUM ( Table2[Q1 Budget] ), ALLSELECTED ( Table1 ) )
VAR Q2Budget =
    CALCULATE ( SUM ( Table2[Q2 Budget] ), ALLSELECTED ( Table1 ) )
VAR Q3Budget =
    CALCULATE ( SUM ( Table2[Q3 Budget] ), ALLSELECTED ( Table1 ) )
VAR Q4Budget =
    CALCULATE ( SUM ( Table2[Q4 Budget] ), ALLSELECTED ( Table1 ) )
RETURN
    SWITCH (
        YearQuarter,
        201701, Q1Budget,
        201702, Q2Budget,
        201703, Q3Budget,
        201704, Q4Budget,
        Q1Budget + Q2Budget
            + Q3Budget
            + Q4Budget
    )
Coverage_2 = 
ROUND ( [Pipeline_2] / [Budget_2], 1 )
& "x"

Multiple IF functions_1.jpg

 

Best Regards,

Herbert

Anonymous
Not applicable

Thank you @v-haibl-msft..! Used some parts of the formulas you sent. Works now!

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.