Forum Discussion

srkase's avatar
srkase
Helper IV
6 years ago
Solved

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..

 

 

 

  • srkase's avatar
    srkase
    6 years ago

    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))

     

7 Replies

  • mussaenda's avatar
    mussaenda
    Community Champion

    Hi srkase ,

     

    thanks for explaining clearly.

    Here's the output from your provided data.

     

    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)
    • srkase's avatar
      srkase
      Helper IV

      Dear Mussaedna ,

       

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

       

      but couldnt get the result

       

      • mussaenda's avatar
        mussaenda
        Community Champion

        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.