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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
kalavala
Frequent Visitor

DAX

How to write the formula Power bi in DAX

Sum(Case When (columnname) < 10 Then 1 Else 0 End) Over (Partition By ColumnName)

1 ACCEPTED SOLUTION
Reid_Havens
Most Valuable Professional
Most Valuable Professional

Hi there,

 

So the EARLIER function is grouping by values in a specified column, so those column names need to be the same, in the example below you're using ColumnName1 against ColumnName, those should match and then the query should work.

View solution in original post

4 REPLIES 4
Eric_Zhang
Microsoft Employee
Microsoft Employee


@kalavala wrote:

How to write the formula Power bi in DAX

Sum(Case When (columnname) < 10 Then 1 Else 0 End) Over (Partition By ColumnName)


@kalavala

Besides @Reid_Havens's solution, or a more intuitive approach.

Measure =
SUMX ( Table1, SWITCH ( TRUE (), Table1[Column1] < 10, 1, 0 ) )
Reid_Havens
Most Valuable Professional
Most Valuable Professional

Hi there,

 

Happy to help!


So it looks like you're wanting a count of rows when [ColumnName] is less than 10 correct? It also seems you're using the OVER partition to group by the [ColumnName] values for the count? If that is the case then a DAX Measure could look like:

 

=
CALCULATE (
    COUNTA ( [ColumnName] ),
    [ColumnName] < 10,
    FILTER ( TableName, [ColumnName] = EARLIER ( [ColumnName] ) )
)

Hope this helps!

 

Reid Havens - Owner

Havens Consulting Inc.

Hello  Havens,

 

 the below calcuation part columnname 1 

DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.

please help me 

=
CALCULATE (
    COUNTA ( [ColumnName] ),
    [ColumnName] < 10,
    FILTER ( TableName, [ColumnName1] = EARLIER ( [ColumnName] ) )
)

 

Reid_Havens
Most Valuable Professional
Most Valuable Professional

Hi there,

 

So the EARLIER function is grouping by values in a specified column, so those column names need to be the same, in the example below you're using ColumnName1 against ColumnName, those should match and then the query should work.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.

Top Solution Authors