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
srkase
Helper IV
Helper IV

MULTIPLE FILTRATION

I have the data like this...

 

YEARSHORTNAMEDEALERTYPEPRODUCTAPRMAYJUNJULAUGSEPOCTNOVDECJANFEBMARTOTCATEGORY
20182019ABASTDPROD100000000000010PRODUCT
20182019ACBSTDPROD200000000000020PRODUCT
20182019ADASTDPROD300000000000030PRODUCT
20182019ABASTDCAB0401000000000050CAB
20182019ABASTDCAB0501000000000060CAB
20182019ACASTDCAB000505050505050505050450CAB
20182019ADASTDCAB000505050505050505050450CAB
20192020ABASTDPROD100000000000010PRODUCT
20192020ACBSTDPROD200000000000020PRODUCT
20192020ADASTDPROD300000000000030PRODUCT
20192020ABASTDCAB0401000000000050CAB
20192020ABASTDCAB0501000000000060CAB
20192020ACASTDCAB000505050505050505050450CAB
20192020ADASTDCAB000505050505050505050450CAB

 

I Want a result like this

I want COUNT OF DEALERS SAY  
     
MONTH DEALERSQTY<10QTY>10<=20QTY>=30
APRIL6222
MAY4004

 

Please guide me..

 

 

 

1 ACCEPTED SOLUTION


@v-chuncz-msft wrote:

@srkase 

 

You may use the following measure.

Measure =
COUNTROWS (
    FILTER ( VALUES ( cab[DEALER] ), CALCULATE ( SUM ( cab[QTY] ) <= 1000 ) )
)

it gives only true or false...

 

I applied this measure ... and works fine..

 

qty500 = CALCULATE (
DISTINCTCOUNT('BREAKUP CABLES'[DEALER] ),
FILTER ( ALL ( 'BREAKUP CABLES'[DEALER] ), 'BREAKUP CABLES'[sumqty]<=499))

 

View solution in original post

7 REPLIES 7
mussaenda
Super User
Super User

Hi @srkase ,

 

thanks for explaining clearly.

Here's the output from your provided data.

 

2019_09_02_13_01_10_Untitled_Power_BI_Desktop.png

Here are the steps. I just unpivot the months and filtered the qty <> 0

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtABiSyUdJUcnEAHEwSEuQDIgyB9EGRoACVIwWANIc6hziFKsDqoVzkDCCd0KI1KtMMJnhQs2XxiTaoUxPitQA8oZzAepN4H7nxhsagDVTKzxpiQZb4bLeGccxqO4i1jCBKcvXGhqjaWRATgV0DDRwq2gXaKFW0G7RIsjoKiVaAkaT1miRYkDOqQmWiXaWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [YEAR = _t, SHORTNAME = _t, DEALER = _t, TYPE = _t, PRODUCT = _t, APR = _t, MAY = _t, JUN = _t, JUL = _t, AUG = _t, SEP = _t, OCT = _t, NOV = _t, DEC = _t, JAN = _t, FEB = _t, MAR = _t, TOT = _t, CATEGORY = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"YEAR", Int64.Type}, {"SHORTNAME", type text}, {"DEALER", type text}, {"TYPE", type text}, {"PRODUCT", type text}, {"APR", Int64.Type}, {"MAY", Int64.Type}, {"JUN", Int64.Type}, {"JUL", Int64.Type}, {"AUG", Int64.Type}, {"SEP", Int64.Type}, {"OCT", Int64.Type}, {"NOV", Int64.Type}, {"DEC", Int64.Type}, {"JAN", Int64.Type}, {"FEB", Int64.Type}, {"MAR", Int64.Type}, {"TOT", Int64.Type}, {"CATEGORY", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"YEAR", "SHORTNAME", "DEALER", "TYPE", "PRODUCT", "TOT", "CATEGORY"}, "Attribute", "Value"),
    #"Renamed Columns" = Table.RenameColumns(#"Unpivoted Columns",{{"Attribute", "Month"}, {"Value", "Qty"}}),
    #"Filtered Rows" = Table.SelectRows(#"Renamed Columns", each ([Qty] <> 0))
in
    #"Filtered Rows"

 

measures for the qty:

 

Qty<10 = CALCULATE(COUNT('Table'[DEALER]), 'Table'[Qty] <=10)
Qty<20 = CALCULATE(COUNT('Table'[DEALER]), 'Table'[Qty] >10 && 'Table'[Qty] <=20)
Qty>30 = CALCULATE(COUNT('Table'[DEALER]), 'Table'[Qty] >=30)

Dear Mussaedna ,

 

I have used query editor to unpivot the data and applied the measure what you have given,,,

 

but couldnt get the result

 

If you will try it on the data you gave, it will work.

 

if it didn't work, you should at least explain why or what problem you have encountered so it can be resolved.

 

Thank you.

THIS WAS THE SAMPLE DATA

 

YEARSHORTNAMEDEALERTYPEPRODUCTCATEGORYMONTHQTY
20192020CBEASTDACABLEAPR1000
20192020CBEASTDBCABLEAPR3000
20192020CBEASTDACABLEAPR1738
20192020CBEASTDBCABLEAPR3000
20192020CBEASTDACABLEAPR3940
20192020CBEBSTDBCABLEAPR1000
20192020CBECSTDACABLEAPR1000
20192020CBECSTDBCABLEAPR1800
20192020CBECSTDACABLEAPR3000
20192020CBEDSTDBCABLEAPR1000
20192020CBEDSTDACABLEAPR1000
20192020CBEDSTDBCABLEAPR2869
20192020CBEDSTDACABLEAPR3000
20192020CBEESTDBCABLEAPR1000
20192020CBEESTDACABLEAPR872
20192020CBEESTDBCABLEAPR4000
20192020CBEFSTDACABLEAPR1000
20192020CBEFSTDBCABLEAPR2000
20192020CBEGSTDACABLEAPR1000
20192020CBEGSTDBCABLEAPR1000
20192020CBEGSTDACABLEAPR2000
20192020CBEGSTDBCABLEAPR6000
20192020CBEHSTDACABLEAPR2000
20192020CBEISTDBCABLEAPR2000
20192020CBEISTDACABLEAPR3877
20192020CBEISTDBCABLEAPR4000
20192020CBEJSTDACABLEAPR1000
20192020CBEJSTDBCABLEAPR2000
20192020CBEJSTDACABLEAPR6000
20192020CBEKSTDBCABLEAPR1000
20192020CBEKSTDACABLEAPR4000
20192020CBELSTDBCABLEAPR1000
20192020CBELSTDACABLEAPR890
20192020CBEMSTDBCABLEAPR2000
20192020CBEMSTDACABLEAPR6000
20192020CBEMSTDBCABLEAPR12000
20182019CBEMSTDACABLEAPR6000
20182019CBEMSTDBCABLEAPR12000
20182019CBEMSTDACABLEAPR1000
20182019CBEMSTDBCABLEAPR3000
20182019CBEMSTDACABLEAPR1738
20182019CBEMSTDBCABLEAPR3000
20182019CBEMSTDACABLEAPR3940
20182019CBELSTDBCABLEAPR1000
20182019CBEKSTDACABLEAPR1000
20182019CBEKSTDBCABLEAPR1800
20182019CBEKSTDACABLEAPR3000
20182019CBEISTDBCABLEAPR1000
20182019CBEISTDACABLEAPR1000
20182019CBEISTDBCABLEAPR2869
20182019CBEISTDACABLEAPR3000
20182019CBEJSTDBCABLEAPR1000
20182019CBEJSTDACABLEAPR872
20182019CBEJSTDBCABLEAPR4000
20182019CBEASTDACABLEAPR2000
20182019CBEASTDBCABLEAPR6000
20182019CBEASTDACABLEAPR12000
20182019CBEASTDBCABLEAPR6000
20182019CBEASTDACABLEAPR12000

 

The measure i have used to filter <1000,

Qty<1000 = CALCULATE(COUNT('cab'[DEALER]),cab[QTY] <=1000)
 
the result i get is
 
Month  Count of Dealer   Qty<1000
April              13                       21
 
I have kept distinct count of dealer
 
Results are wrong
 
 

 

In a month a dealer might have taken items in many invoices... The sum we should check and get the total and then the measures should be applied..

 

@srkase 

 

You may use the following measure.

Measure =
COUNTROWS (
    FILTER ( VALUES ( cab[DEALER] ), CALCULATE ( SUM ( cab[QTY] ) <= 1000 ) )
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.


@v-chuncz-msft wrote:

@srkase 

 

You may use the following measure.

Measure =
COUNTROWS (
    FILTER ( VALUES ( cab[DEALER] ), CALCULATE ( SUM ( cab[QTY] ) <= 1000 ) )
)

it gives only true or false...

 

I applied this measure ... and works fine..

 

qty500 = CALCULATE (
DISTINCTCOUNT('BREAKUP CABLES'[DEALER] ),
FILTER ( ALL ( 'BREAKUP CABLES'[DEALER] ), 'BREAKUP CABLES'[sumqty]<=499))

 

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.