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

DAX measure that has a top level name that filters for three companies

Hello, I'm using the below DAX to create a measure that filters for three companies. I've also tried SUMX then filter. Neither worked. Any suggestions are appreciated. Thanks.
 
DAX
TopLevelName=
FILTER(
    'SEC',
    'SEC'[CompanyDBA] IN {"Company1", "Company2", "Company3"}
)
 
Error Message I'm getting
The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.
1 ACCEPTED SOLUTION

Thanks. Got an error message with the above DAX. This ended up working ---

PrimeSales =
CALCULATE (
    COUNTROWS('RevenueAll_V'),
    FILTER(
    'RevenueAll_V',
    'RevenueAll_V'[CompanyDBA] IN {"Company1", "Company2", "Company3"}
))

View solution in original post

3 REPLIES 3
AmiraBedh
Resident Rockstar
Resident Rockstar

You are encountering this error because you are trying to create a measure, but the DAX expression you’ve provided returns a table, not a scalar value. Measures should always return a single value.

If you are trying to create a measure that sums a certain column for those three companies, you might use CALCULATE combined with FILTER. Here is an example assuming you want to sum a column named "Value":

 

TopLevelValueSum =
CALCULATE (
    SUM ( 'SEC'[Value] ),
    FILTER (
        'SEC',
        'SEC'[CompanyDBA] IN { "Company1", "Company2", "Company3" }
    )
)

Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Thanks. Got an error message with the above DAX. This ended up working ---

PrimeSales =
CALCULATE (
    COUNTROWS('RevenueAll_V'),
    FILTER(
    'RevenueAll_V',
    'RevenueAll_V'[CompanyDBA] IN {"Company1", "Company2", "Company3"}
))

My answer is correct, you didn't precise if you want to sum or count the rows.


Proud to be a Power BI Super User !

Microsoft Community : https://docs.microsoft.com/en-us/users/AmiraBedhiafi
Linkedin : https://www.linkedin.com/in/amira-bedhiafi/
StackOverflow : https://stackoverflow.com/users/9517769/amira-bedhiafi
C-Sharp Corner : https://www.c-sharpcorner.com/members/amira-bedhiafi
Power BI Community :https://community.powerbi.com/t5/user/viewprofilepage/user-id/332696

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Fabric Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.