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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Joakim_gg
Frequent Visitor

Convert Excel formula to DAX

Hi,

 

As I'm fairly new to Power BI I have a formula in Excel which I would like some input on how to use in Power BI. 

 

The formula is as follows: 

 

=IF(COUNT(I7:Q7)>0;(((IF(I7="";0;I7))+(IF(J7="";0;J7))+(IF(L7="";0;L7))+(IF(N7="";0;N7))+(IF(O7="";0;O7))+(IF(K7="";0;(5-K7)))+(IF(M7="";0;(5-M7)))+(IF(P7="";0;(5-P7)))+(IF(Q7="";0;(5-Q7))))/COUNT(I7:Q7));"")

 

Any help is much appreciated. Thanks!

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Joakim_gg ,

If you want to achieve it using DAX in Power BI, you need to create a reference unpviot table like this in Power Query first:

vyingjl_1-1635833488178.png

 

vyingjl_0-1635833478105.png

Create a calculated column like this:

Result = 
VAR _count =
    CALCULATE (
        COUNTROWS ( 'Reference table' ),
        FILTER (
            'Reference table',
            'Reference table'[Category] = EARLIER ( 'Table'[Category] )
        )
    )
VAR A =
    IF ( [Column1] = BLANK (), 0, [Column1] )
VAR B =
    IF ( [Column2] = BLANK (), 0, [Column2] )
VAR C =
    IF ( [Column4] = BLANK (), 0, [Column4] )
VAR D =
    IF ( [Column6] = BLANK (), 0, [Column6] )
VAR E =
    IF ( [Column7] = BLANK (), 0, [Column7] )
VAR F =
    IF ( [Column3] = BLANK (), 0, 5 - [Column3] )
VAR G =
    IF ( [Column5] = BLANK (), 0, 5 - [Column5] )
VAR H =
    IF ( [Column8] = BLANK (), 0, 5 - [Column8] )
VAR I =
    IF ( [Column9] = BLANK (), 0, 5 - [Column9] )
VAR result =
    IF ( _count > 0, ( A + B + C + D + E + F + G + H + I ) / _count, BLANK () )
RETURN
    result

vyingjl_2-1635833543439.png

 

Best Regards,
Community Support Team _ Yingjie Li
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

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @Joakim_gg ,

If you want to achieve it using DAX in Power BI, you need to create a reference unpviot table like this in Power Query first:

vyingjl_1-1635833488178.png

 

vyingjl_0-1635833478105.png

Create a calculated column like this:

Result = 
VAR _count =
    CALCULATE (
        COUNTROWS ( 'Reference table' ),
        FILTER (
            'Reference table',
            'Reference table'[Category] = EARLIER ( 'Table'[Category] )
        )
    )
VAR A =
    IF ( [Column1] = BLANK (), 0, [Column1] )
VAR B =
    IF ( [Column2] = BLANK (), 0, [Column2] )
VAR C =
    IF ( [Column4] = BLANK (), 0, [Column4] )
VAR D =
    IF ( [Column6] = BLANK (), 0, [Column6] )
VAR E =
    IF ( [Column7] = BLANK (), 0, [Column7] )
VAR F =
    IF ( [Column3] = BLANK (), 0, 5 - [Column3] )
VAR G =
    IF ( [Column5] = BLANK (), 0, 5 - [Column5] )
VAR H =
    IF ( [Column8] = BLANK (), 0, 5 - [Column8] )
VAR I =
    IF ( [Column9] = BLANK (), 0, 5 - [Column9] )
VAR result =
    IF ( _count > 0, ( A + B + C + D + E + F + G + H + I ) / _count, BLANK () )
RETURN
    result

vyingjl_2-1635833543439.png

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

HotChilli
Community Champion
Community Champion

Hello, welcome to the forum.

Can you repost your question please?

Please provide a small amount of sample data and the desired output (with an explanation of how to get there)

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.