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
Anonymous
Not applicable

Excel DAX to Power BI

Hello and Happy Friday!

 

I am trying to recreate a Excel report in Power BI and I am almost there but I am having trouble with 2 calculations and how to convert the syntax that is in Excel over to Power BI DAX.

 

The Excel report uses a COUNTIF vs something like - 

 

TMTM1 =
CALCULATE (
COUNTA( 'All Data'[TechNameCompare1] ),ALLEXCEPT('All Data', 'All Data'[TechMatch])
)

 

2019-05-31_7-56-08.png2019-05-31_7-56-23.png

 

Suggestions?

 

1 ACCEPTED SOLUTION
v-cherch-msft
Employee
Employee

Hi @Anonymous 

You may try to use FIND function to get the two columns.For example:

Column =
CALCULATE (
    COUNTROWS ( 'Sample' ),
    FILTER (
        ALLEXCEPT ( 'Sample', 'Sample'[TechName] ),
        FIND ( "Exists in both GoCanvas and e-automate", 'Sample'[TechMatch], 1, 0 ) > 0
            && FIND ( "MAC", 'Sample'[MAC?], 1, 0 ) > 0
            && FIND ( "Exist", 'Sample'[MAC?], 1, 0 ) > 0
    )
)
Column 2 =
CALCULATE (
    COUNTROWS ( 'Sample' ),
    FILTER (
        ALLEXCEPT ( 'Sample', 'Sample'[TechName] ),
        FIND ( "Exists in both GoCanvas and e-automate", 'Sample'[TechMatch], 1, 0 ) > 0
            || FIND ( "e-automate Only,not in GoCanvas", 'Sample'[TechMatch], 1, 0 ) > 0
    )
)

1.png

Regards,

Community Support Team _ Cherie Chen
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
v-cherch-msft
Employee
Employee

Hi @Anonymous 

You may try to use FIND function to get the two columns.For example:

Column =
CALCULATE (
    COUNTROWS ( 'Sample' ),
    FILTER (
        ALLEXCEPT ( 'Sample', 'Sample'[TechName] ),
        FIND ( "Exists in both GoCanvas and e-automate", 'Sample'[TechMatch], 1, 0 ) > 0
            && FIND ( "MAC", 'Sample'[MAC?], 1, 0 ) > 0
            && FIND ( "Exist", 'Sample'[MAC?], 1, 0 ) > 0
    )
)
Column 2 =
CALCULATE (
    COUNTROWS ( 'Sample' ),
    FILTER (
        ALLEXCEPT ( 'Sample', 'Sample'[TechName] ),
        FIND ( "Exists in both GoCanvas and e-automate", 'Sample'[TechMatch], 1, 0 ) > 0
            || FIND ( "e-automate Only,not in GoCanvas", 'Sample'[TechMatch], 1, 0 ) > 0
    )
)

1.png

Regards,

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Here is what I ended up with that seems to get me what I needed.

Thank you so much!

 

TMTM1 = IF(CALCULATE ( COUNTROWS ( 'All Data' ),
        FILTER ( ALLEXCEPT ( 'All Data', 'All Data'[TechName] ),
            FIND ( "Exists in both GoCanvas and e-automate", 'All Data'[TechMatch], 1, 0 ) > 0 ||
            FIND ( "MAC Exists", 'All Data'[MacMatch], 1, 0 ) > 0 ) ) > 0,
                CALCULATE ( COUNTROWS ( 'All Data' ),
                    FILTER ( ALLEXCEPT ( 'All Data', 'All Data'[TechName] ),
                        FIND ( "Exists in both GoCanvas and e-automate", 'All Data'[TechMatch], 1, 0 ) > 0 ||
                        FIND ( "MAC Exists", 'All Data'[MacMatch], 1, 0 ) > 0 ) ), 0)
  
TMTM4 = IF(CALCULATE ( COUNTROWS ( 'All Data' ),
    FILTER ( ALLEXCEPT ( 'All Data', 'All Data'[TechName] ),
        FIND ( "Exists in both GoCanvas and e-automate", 'All Data'[TechMatch], 1, 0 ) > 0 ||
FIND ( "e-automate Only, not in GoCanvas", 'All Data'[TechMatch], 1, 0 ) > 0 ) ) > 0 ,
            CALCULATE ( COUNTROWS ( 'All Data' ),
                FILTER ( ALLEXCEPT ( 'All Data', 'All Data'[TechName] ),
                    FIND ( "Exists in both GoCanvas and e-automate", 'All Data'[TechMatch], 1, 0 ) > 0 ||
                    FIND ( "e-automate Only, not in GoCanvas", 'All Data'[TechMatch], 1, 0 ) > 0 ) ),0)
Anonymous
Not applicable

AWESOME!!

 

One last question, where would I add an ELSE to return 0 so that the field is populated with a value?

 

Thank you SO MUCH!!

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.