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
Syndicate_Admin
Administrator
Administrator

How to put COUNT within IF

Good afternoon!

I explained my problem.

I have this column with several values:

mariases94_1-1663329814447.png

The values in this column can be: 001N, 002N, 003N, 004N, 005N.

Depending on the value, you have to do the following:

If Code Nuevas = 001N, then COUNT(Opportunity[Opportunity] * (0.10)

If Code Nuevas = 002N, then COUNT(Opportunity[Opportunity] * (0.15)

If Code Nuevas = 003N, then COUNT(Opportunity[Opportunity] * (0.50)

If Code Nuevas = 004N, then COUNT(Opportunity[Opportunity] * (0.20)

If Code Nuevas = 005N, then COUNT(Opportunity[Opportunity] * (0.05)

How can I do this to make it work out for me?

I've tried it to one extent (the IF doesn't work with columns for me)...

Can you help me please?

Thank you!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@Syndicate_Admin Use SWITCH like:

Measure = 
  VAR __Code = MAX('Table'[Code Nuevas])
RETURN
  SWITCH(__Code,
    "001N",COUNT(Opportunity[Opportunity])*.1,
    ...
  )

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Super User
Super User

@Syndicate_Admin Use SWITCH like:

Measure = 
  VAR __Code = MAX('Table'[Code Nuevas])
RETURN
  SWITCH(__Code,
    "001N",COUNT(Opportunity[Opportunity])*.1,
    ...
  )

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.