• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Power BI Query: Using IF

Jyot

New Member
Hi,


I tried to make a new measure using IF. Here is the dax code

ICSEA Count = IF([ICSEA Eligibility]= "ICSEA Eligible",1,0)

Not sure why this is not working, I cannot upload a Power BI file.


Thanks for the help.
 
Upload the data (sample) in Excel file. Along with relationship description between tables.

We can easily recreate model from Excel file.
 
Hi Chihiro,

I have uploaded the data. It is only one table where I am trying to add an extra column 'ICSEA Count'.

Thanks
 

Attachments

  • Power BI Query.xlsx
    9.4 KB · Views: 3
Ok, if you are adding calculated column. Your formula works. You'll then use SUM() on the column as measure. Note that I added Custom column to turn even rows to "ICSEA Eligible" as all your record were for "ICSEA Not Eligible".
upload_2018-8-30_9-0-26.png


However, I'd advise against adding this type of calculated column (it does not reduce filter context, and is a bit pointless). Calculated columns should mainly reside in Dimension table.

To count using condition in DAX, there are several ways. In this case, since all data is based on single table, you can simply use COUNTROWS() with filter.
ex:
Measure = COUNTROWS(Filter(Table1,[ICSEA Eligible]="ICSEA Eligible")

Alternately...
Measure = CALCULATE(COUNTA(Table1[ICSEA Eligible]),Table1[ICSEA Eligible]="ICSEA Eligible")
 
Back
Top