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
Matt0515
Frequent Visitor

Measure Using "Or" in a table to Count Rows with multiple qualifiers

Hello,

 

I am struggling to write a DAX Calculation to report the number of records that qualify based on multiple components.

I have tried to use the "OR" function several different ways and the only one I can get to work provides me with the incorrect count. (code below)

 

I know I should have 19 qualified lines using this logic.

     Opportunity Solution = X and Created Date Year = 2020

Plus

     Opportunity Solution = Y and Created Date Year = 2020

 

However, based on the below code I receive the count of 63.

 

2020 TMS/WS MKT MQL2 =
CALCULATE (
    COUNTROWS ( Raw_Data ),
    FILTER (
        ALLSELECTED ( Raw_Data ),
        OR(Raw_Data[Opportunity Solution] = "X"
            && YEAR ( Raw_Data[Created Date] ) = 2020,
        Raw_Data[Opportunity Solution] = "Y"
            && YEAR ( Raw_Data[Created Date] ) = 2020
       
    )
)))
 
Can someone please help me understand how to write the measure that will result in the total of lines that
meet both requirements?
1 ACCEPTED SOLUTION
deevaker
Resolver I
Resolver I

Try this one :

 

2020 TMS/WS MKT MQL2 =
CALCULATE (
    COUNTROWS ( Raw_Data ),
    FILTER (
        ALLSELECTED ( Raw_Data ),
YEAR ( Raw_Data[Created Date] ) = 2020 &&
(Raw_Data[Opportunity Solution] = "X" || Raw_Data[Opportunity Solution] = "Y")
))

View solution in original post

2 REPLIES 2
deevaker
Resolver I
Resolver I

Try this one :

 

2020 TMS/WS MKT MQL2 =
CALCULATE (
    COUNTROWS ( Raw_Data ),
    FILTER (
        ALLSELECTED ( Raw_Data ),
YEAR ( Raw_Data[Created Date] ) = 2020 &&
(Raw_Data[Opportunity Solution] = "X" || Raw_Data[Opportunity Solution] = "Y")
))
vivran22
Community Champion
Community Champion

Hello @Matt0515 ,

 

Try this:

 

Measure 2020 = 

VAR _Filter2020 = 
    FILTER('Table',
        'Table'[Created Date Year] = 2020
        )

VAR _Count = 
    CALCULATE(
        COUNTROWS('Table'),
        _Filter2020,
        'Table'[Opportunity Solution] = "X" || 'Table'[Opportunity Solution] = "Y"
    )

RETURN

_Count

 

Cheers!
Vivek

If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂

https://www.vivran.in/

Connect on LinkedIn

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.

Top Solution Authors