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
afaherty
Helper IV
Helper IV

DAX Formula Help - Should be easy!

Hello!

I am fairly new to PowerBI and DAX as well.  What I am trying to accomplish is a column to calculate the number of times the "MAIN" campus appears for Fall 2019 and Spring 2020 (from the "Term" Column).  Same for the "OTHTU" and "OTHEX" campuses.  There is more to the dataset, but this is the only part I'm having troubles with.  Can anyone help?  Screenshot below - I figured the PBIX file wouldn't be needed.  Thanks SO much!

 

PBI Screenshot.JPG

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Have you tried making a matrix visual with Term on the rows, Campus on the columns, and making a simple measure like Campus Count = COUNTROWS(Table)?  Your post requested a column, but is that needed?  Many people do more columns than necessary when they first start out, which is why I'm asking.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

5 REPLIES 5
v-alq-msft
Community Support
Community Support

Hi, @afaherty 


Based on your description, I created data to reproduce your scenario.

Table:

e2.png

 

You may try measures as below.

NumMain = 
COUNTROWS(
    FILTER(
        ALL('Table'),
        OR(
            'Table'[Term]="Spring 2020",
            'Table'[Term]="Fall 2019"
        )&&
        'Table'[Campus]="MAIN"
    )
)

NumOTHEX = 
COUNTROWS(
    FILTER(
        ALL('Table'),
        OR(
            'Table'[Term]="Spring 2020",
            'Table'[Term]="Fall 2019"
        )&&
        'Table'[Campus]="OTHEX"
    )
)

NumOTHTU = 
COUNTROWS(
    FILTER(
        ALL('Table'),
        OR(
            'Table'[Term]="Spring 2020",
            'Table'[Term]="Fall 2019"
        )&&
        'Table'[Campus]="OTHTU"
    )
)

 

Result:

e1.png

 

Best Regards

Allan

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Employee
Employee

Have you tried making a matrix visual with Term on the rows, Campus on the columns, and making a simple measure like Campus Count = COUNTROWS(Table)?  Your post requested a column, but is that needed?  Many people do more columns than necessary when they first start out, which is why I'm asking.

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Use the logical operator || (OR) to combine additional values in your FILTER
Measure = COUNTX(FILTER(Query1,[Campus]="MAIN" || [Campus]="OTHEX"),[Term])

HTH,

Smitty

Anonymous
Not applicable

Try the COUNTX in a new Measure:  

Measure = COUNTX(FILTER(Query1,[Campus]="MAIN"),[Term])
HTH,
Smitty

@Anonymous Thanks! How would I nest the other 2 Campuses (OTHTU and OTHEX) within that?

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.