Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.