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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
topalych
Frequent Visitor

Formula DAX such as COUNTIF in Excel

Hello! Help me please. 

I need formula DAX.

There is a table:

 

Campaign    Cost     ClientID

First            900        0001

First            900        0002

First            900        0003

Second       1000       0004

Second       1000       0005

Third           300        0006

 

I spent 2200 USD on three campaigns. 900 USD on "First", 1000 USD on "Second" and 300 USD on "Third".

And I got 6 Clients. I want to see how much I spent to get each Client.

 

What should I do to see 300 USD in "First"? Because it repeats 3 times.

The same thing with "Second". There should be 500 USD. Cause I got 2 clients from that Campaign and spent 1000 USD.


In Excel, it is easy to make))

=B2/COUNTIF(A:A;A2)

 

I'll be very appreciate for help!

 

 

10 REPLIES 10
v-shex-msft
Community Support
Community Support

Hi @topalych,

 

Vvelarde's formula seems well, you can also use blew formula:

 

Measure:

 

Current Cost = 
var currCampaign=LASTNONBLANK(Table1[Campaign],[Campaign])
Return
DIVIDE(MIN([Cost]),COUNTAX(FILTER(ALL(Table1),[Campaign]=currCampaign),[Campaign]))

 

Capture.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.

@v-shex-msft @Vvelarde

Thank You for answer. But it didn't work( 

I have data from different tables.

http://prntscr.com/czzjss

http://prntscr.com/czzlpp

 

And how can I add screenshots here?)

Hi @topalych,

 

Can you share us some sample data to test?

 

>>And how can I add screenshots here?

You can use the camera button to insert the picture.

Capture.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.

Yes, course!

What eMail?

Hi @topalych,

 

You can upload to 1drive and share a link.

 

Regards,

Xiaoxin Sheng

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

@v-shex-msft, Did You get the file?

Hi @topalych,

 

Yes, I download it. But I faced a trouble(complex relationship) to merge multiple table columns to one and write a measure to calculate them.

 

Regards,

Xiaoxin Sheng

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

Thank You anyway!)

Vvelarde
Community Champion
Community Champion

@topalych

 

Hello, use this measure

 

CostCampaign = DIVIDE(CALCULATE(Min(Table1[Cost]));COUNTROWS(Table1))

 

Sin título.png




Lima - Peru

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.