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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Power_BI_Adapt
Resolver I
Resolver I

Expand measure with exclusion of some entries

Dear All,

 

I have written the following measure:

 

Number of delivery customer numbers =
VAR _SummTable =
    SUMMARIZE ( 'Tbl_Sales', 'Tbl_customer'[Deliverycustnr] )
VAR Result =
    SUMX ( _SummTable, 1 )      
RETURN
    Result
 
 
The result is showing the total number of delivery customer numbers for a customer. The table 'Tbl_customer' also contains a field called  'deliverycustname' (Tbl_customer'[deliverycustname]. Some exceptions for the description exist. In addition to the normal descriptions, it gives three type of descriptions which I want to exclude from the result in the measure. My question is how I can add these exclusion to the measure? The three types of descriptions are:
 
* Descriptions starting with PP_
* Descriptions starting with BX_
* Descriptions starting with PD_
 
Delivery customer numbers with such descriptions of delivery name should be excluded from the count in the measure. 
 
A simplified table situation to illustrate:
 
Power_BI_Adapt_0-1694423119820.png

 

The current measure does count 5 different delivery customer numbers. In the new situation three records should be excluded, so the final result of the new measure should be 2 different delivery customer numbers.

 

Thanks in advance for any suggestion to improve the measure. 

 
1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Power_BI_Adapt ,

 

 

Here are the steps you can follow:

1. Create measure.

count1 =
var _table1=
FILTER(
    'Tbl_customer',       SEARCH("PP_",'Tbl_customer'[Deliveryname],1,BLANK())=1&&CONTAINSSTRING('Tbl_customer'[Deliveryname],"PP_")=TRUE() ||       SEARCH("BX_",'Tbl_customer'[Deliveryname],1,BLANK())=1&&CONTAINSSTRING('Tbl_customer'[Deliveryname],"BX_")=TRUE() ||    SEARCH("PD_",'Tbl_customer'[Deliveryname],1,BLANK())=1&&CONTAINSSTRING('Tbl_customer'[Deliveryname],"PD_")=TRUE() )
return
IF(
    MAX('Tbl_customer'[Deliveryname]) in SELECTCOLUMNS(_table1,"flag",[Deliveryname]),0,1)
count2 =
SUMX(ALL(Tbl_customer),[count1])

2. Result:

 

vyangliumsft_0-1694587042988.png

 

Best Regards,

Liu Yang

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

View solution in original post

2 REPLIES 2
v-yangliu-msft
Community Support
Community Support

Hi  @Power_BI_Adapt ,

 

 

Here are the steps you can follow:

1. Create measure.

count1 =
var _table1=
FILTER(
    'Tbl_customer',       SEARCH("PP_",'Tbl_customer'[Deliveryname],1,BLANK())=1&&CONTAINSSTRING('Tbl_customer'[Deliveryname],"PP_")=TRUE() ||       SEARCH("BX_",'Tbl_customer'[Deliveryname],1,BLANK())=1&&CONTAINSSTRING('Tbl_customer'[Deliveryname],"BX_")=TRUE() ||    SEARCH("PD_",'Tbl_customer'[Deliveryname],1,BLANK())=1&&CONTAINSSTRING('Tbl_customer'[Deliveryname],"PD_")=TRUE() )
return
IF(
    MAX('Tbl_customer'[Deliveryname]) in SELECTCOLUMNS(_table1,"flag",[Deliveryname]),0,1)
count2 =
SUMX(ALL(Tbl_customer),[count1])

2. Result:

 

vyangliumsft_0-1694587042988.png

 

Best Regards,

Liu Yang

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

Thanks a lot for your suggestion and it works quite well. I only miss a sum of the total number, so it just points out as '1''. In my original measure I make use of a SUMX, which rings me to a total number of delivery customer names for a specific customer . With the proposed measure it just turns out to 1 delivery customer name.

 

Thanks in adavcen for any additional thought to get this resolved.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.