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
mmace1
Impactful Individual
Impactful Individual

Is there a significantly cleaner way to write this Measure?

Say I have this measure, which is certainly direct: 

 

# Card payments =
calculate([# of Total Pmts], Payment[PaymentTypeID] = 2) +
calculate([# of Total Pmts], Payment[Payment Type] = 3) + 

calculate([# of Total Pmts], Payment[Payment Type] = 5) +

calculate([# of Total Pmts], Payment[Payment Type] = 7) +

calculate([# of Total Pmts], Payment[Payment Type] = 😎 +

calculate([# of Total Pmts], Payment[Payment Type] = 9) +

calculate([# of Total Pmts], Payment[Payment Type] = 11)

 

But say in SQL, one could do something like: 

 

SELECT

      COUNT(p.id)

WHERE

      p.type IN (2,3,5,7,8,9,11)

FROM

      TableTable p

 

I'm kinda missing the IN here.  There's definitely different ways to write my measure above, but what way would be the cleanest/fastest to write? 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION
Hardik
Continued Contributor
Continued Contributor

Go for the containsrow function in dax to solve the query.I hope this helps ! feel free to reavh out,oif the problem still persists

 Card payments =calculate([# of Total Pmts],CONTAINSROW ({2,3,5,7,8,9,11},

      Payment[Payment Type]
    )
)

View solution in original post

1 REPLY 1
Hardik
Continued Contributor
Continued Contributor

Go for the containsrow function in dax to solve the query.I hope this helps ! feel free to reavh out,oif the problem still persists

 Card payments =calculate([# of Total Pmts],CONTAINSROW ({2,3,5,7,8,9,11},

      Payment[Payment Type]
    )
)

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.