cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
RonaldF Frequent Visitor
Frequent Visitor

Dax

I have an Access database that I have imported into Power BI. I have an "Event" table with fields [EventID], [Year], [Style], [Distance], etc. It is joined to a "Results" table with fields [EventID], [Name], etc.
I have four DAX measures to count participations for each [Name] in four categories: (Long FR, Long CL, Middle FR, Middle FR):
Long CL Participations = CALCULATE(COUNTROWS(Results),Event[Style]="CL",Event[Distance]="Long")
Long FR Participations = CALCULATE(COUNTROWS(Results),Event[Style]="FR",Event[Distance]="Long")
Middle CL Participations = CALCULATE(COUNTROWS(Results),Event[Style]="CL",Event[Distance]="Middle")
Middle FR Participations = CALCULATE(COUNTROWS(Results),Event[Style]="FR",Event[Distance]="Middle")
and then I use:
Total Participations = COUNTROWS(Results)
to get a Total Participations for each [Name].
However I need a DAX measure to count for each [Name] how many Long CL and Long FR events in the same Year they have done. Can you suggest a solution?

1 ACCEPTED SOLUTION

Accepted Solutions
RonaldF Frequent Visitor
Frequent Visitor

Re: Dax

Problem solved,

I found a solution. I created two queries and then merged them on on only the matching fields.

Thanks, RonaldF

5 REPLIES 5
Super User
Super User

Re: Dax

Hi,

 

I suggest that you create slicers from the Event table for Style and Distance.  Simplify your formula to:

 

=COUNTROWS(Results)

As long as your datasets have a proper relationship, you should now be able to slice your visual by any attribute.

 

 

RonaldF Frequent Visitor
Frequent Visitor

Re: Dax

Hello Ashish,

Thanks for your suggestion. I have tried slicers, but what I was trying to do was add a column into my table.

In Access I made two queries: (Count Long FR) and (Count Long CL) and then joined them where [Year] = [Year]

Thanks,

RonaldF

Super User
Super User

Re: Dax

Hi,

 

I am sorry but i cannot appreicate why you need a calculated column when a calculated field (measure) and slicer can solve your problem.  May be i am not understanding your question.

Moderator v-yuezhe-msft
Moderator

Re: Dax

@RonaldF,

Could you please share sample data of the two tables(Event and Results) and post expected result in table?

We also need to know what specific fields you use to create relationship between Event and Results.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
RonaldF Frequent Visitor
Frequent Visitor

Re: Dax

Problem solved,

I found a solution. I created two queries and then merged them on on only the matching fields.

Thanks, RonaldF