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
dpbi
Helper I
Helper I

DAX - COUNTROWS - first occurrence of a value

Hi

I need help to create the 'RESULT TABLE' with a measure in DAX.

 

The 'RESULT TABLE' shows the first occurrence of the number '1' in each column

in the 'BASE TABLE' and returns the row number from the 'INDEX' column.

(The number '1' appears only one time in each row in the BASE TABLE).

 

Thanks for the help

 

 BaseTable.JPG

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

Hi @dpbi

 

How about

 

Measure A =
CALCULATE ( MIN ( BaseTable[Index] ), BaseTable[A] = 1 )


Measure B =
CALCULATE ( MIN ( BaseTable[Index] ), BaseTable[B] = 1 )

Measure C =
CALCULATE ( MIN ( BaseTable[Index] ), BaseTable[C] = 1 )

Regards
Zubair

Please try my custom visuals

View solution in original post

4 REPLIES 4
Zubair_Muhammad
Community Champion
Community Champion

Hi @dpbi

 

How about

 

Measure A =
CALCULATE ( MIN ( BaseTable[Index] ), BaseTable[A] = 1 )


Measure B =
CALCULATE ( MIN ( BaseTable[Index] ), BaseTable[B] = 1 )

Measure C =
CALCULATE ( MIN ( BaseTable[Index] ), BaseTable[C] = 1 )

Regards
Zubair

Please try my custom visuals

Thank you very much for your fast reply.

Your solution works. Thanks again.

 

Is their an option to make the calculation in one measure for all the columns?

(thats why i specified that  the number '1' appear only once in each row)

 

 

Hi @dpbi

 

Yes we can write ONE MEASURE

 

Follow these steps

 

Step #1 Unpivot the 3 Columns

 

30.png

 

You will get

 

31.png

 

Now You can write a single MEASURE

 

Measure =
CALCULATE (
    MIN ( BaseTable[Index] ),
    FILTER ( ALLEXCEPT ( BaseTable, BaseTable[Attribute] ), BaseTable[Value] = 1 )
)

 

 


Regards
Zubair

Please try my custom visuals

Thank you very much again.

Fast replies, working solutions. 

Well appreciated.

Thanks

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.