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
kalavala
Frequent Visitor

DAX

How to write the formula  in DAX

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

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @kalavala,

 

You can refer to below formual about the if statement:

1. Dax.

Calculate column:

Result =IF([columnname]<10,1,0) 

 

 

2. Power Query.

 if [columnname]<10 then 1 else 0

Full query:
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [ID] <10 then 1 else 0)

 

3.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

Hi @kalavala,

 

You can refer to below formual about the if statement:

1. Dax.

Calculate column:

Result =IF([columnname]<10,1,0) 

 

 

2. Power Query.

 if [columnname]<10 then 1 else 0

Full query:
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each if [ID] <10 then 1 else 0)

 

3.PNG

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
I_Like_Pi
Resolver II
Resolver II

Hopefully I am answering your question. I think you are looking for a column not a measure.

In the Data section select the appropriate table, and add a column with an IF statement similar to:

Tst_LT10 = IF(columnname<10, 1,0)

 

Now add a Table to a Report. Add the field you want to partition, the Tst_LT10 field you built, and some other extra field.

in the visualizations Section use the drop button next to Tst_LT10, and select Sum. Similarly use the Drop button on the extra field and select count. You should now have the count of rows that are less than 10 vs the count of rows in general.

 

If this is not what you are looking for please give a bit more detail.

Edit (Spell check)

 

I am writing the if condition in queryeditior facing the below error can please help error.png

 

 

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.

Top Solution Authors