Forum Discussion

akay23's avatar
akay23
Icon for Helper I rankHelper I
4 years ago
Solved

How can I filter a column by another column?

Hi,

 

I am rookie on PBI.

 

I have a measure that first I want the find the all column values [Arr_Airport_Code] in a table that has blank value [frequency] in two months earlier. And than I want to this filtered column's all frequencies. But I can not show the whole year frequency of the values that just two months earlier's frequencys are blank.

 

Here is my measure. Thanks

 

VAR t1 =
SUMMARIZE (
OAG_Deneme_Veri,
OAG_Deneme_Veri[Dep Airport Code],
OAG_Deneme_Veri[Arr_Airport_Code],
OAG_Deneme_Veri[Time series],
OAG_Deneme_Veri[Carrier Code],
 
"frekans", SUM ( OAG_Deneme_Veri[Frequency] )
)
VAR t2 =
ADDCOLUMNS (
t1,
"önceki ay frekans",
CALCULATE (
SUM ( OAG_Deneme_Veri[Frequency] ),
DATEADD (OAG_Deneme_Veri[Time series] , -1, MONTH )
))
VAR t3 =
ADDCOLUMNS (
t2,
"2 önceki ay frekans",
CALCULATE (
SUM ( OAG_Deneme_Veri[Frequency] ),
DATEADD (OAG_Deneme_Veri[Time series] , -2, MONTH ) ))
 
VAR t4 =
ADDCOLUMNS (
t3,
"ddd",
IF ( [önceki ay frekans] = BLANK() && [2 önceki ay frekans] = BLANK(), "Var", "Yok" )
)
 
VAR t5 =
SUMMARIZE(
FILTER ( t4, [ddd] = "Var" ),
OAG_Deneme_Veri[Arr_Airport_Code]

)

Var t6 =
    SUMMARIZE(
    FILTER(OAG_Deneme_Veri, [Arr_Airport_Code] = MINX(t5,[Arr_Airport_Code])),
    
    OAG_Deneme_Veri[Dep Airport Code],
    OAG_Deneme_Veri[Time series],
"aaa", values(OAG_Deneme_Veri[Arr_Airport_Code]),
    "frr" , sum(OAG_Deneme_Veri[Frequency])
    
)
Return
calculate(SUMX(t6,[frr]),ALL())
 
 
 
  • Hi akay23 ,

     

    Maybe you can try REMOVEFILTER('table'[Time Series]). I used to recommend that you use allexcept() to keep the fields you want to keep the filter, all other filters will be removed. You can try it.

     

    Or you can try creating a new table via values('table'[Time Series]) and there no relationship between these tables. Add this field to a slicer,  Filter OAG_Deneme_Veri or other tables by passing values as string from the new table. This can be cumbersome, but it allows you to filter a field individually without affecting other fields that you don't need to filter.

     

    Best Regards

    Community Support Team _ chenwu zhu

10 Replies

  • Hi akay23 

     

    Can you post sample data as text and expected output?
    Not enough information to go on;

    please see this post regarding How to Get Your Question Answered Quickly:
    https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

    The most important parts are:
    1. Sample data as text, use the table tool in the editing bar
    2. Expected output from sample data
    3. Explanation in words of how to get from 1. to 2.
    4. Relation between your tables

    Appreciate your Kudos!!
    LinkedIn:www.linkedin.com/in/vahid-dm/

    • akay23's avatar
      akay23
      Icon for Helper I rankHelper I
      Carrier codeDep Airport CodeArr Airport CodeFrequencyTime Series
      ABABCXYZ01.01.2018
      ABABCXYZ01.02.2018
      ABABCXYZ01.03.2018
      ABABCXYZ01.04.2018
      ABABCXYZ01.05.2018
      ABABCXYZ01.06.2018
      ABABCXYZ01.07.2018
      ABABCXYZ01.08.2018
      ABABCXYZ131.09.2018
      ABABCXYZ141.10.2018
      ABABCXYZ151.11.2018
      ABABCXYZ161.12.2018
      ABABCDFG161.01.2018
      ABABCDFG161.02.2018
      ABABCDFG161.03.2018
      ABABCDFG161.04.2018
      ABABCDFG161.05.2018
      ABABCDFG161.06.2018
      ABABCDFG161.07.2018
      ABABCDFG161.08.2018
      ABABCDFG01.09.2018
      ABABCDFG01.10.2018
      ABABCDFG161.11.2018
      ABABCDFG161.12.2018

       

       

      This is my raw data example. When I select 01/08/2018 on time slicer, I want to data below.

       

       

      Carrier codeDep Airport CodeArr Airport CodeFrequencyTime Series
      ABABCXYZ51.01.2018
      ABABCXYZ61.02.2018
      ABABCXYZ71.03.2018
      ABABCXYZ81.04.2018
      ABABCXYZ91.05.2018
      ABABCXYZ101.06.2018
      ABABCXYZ01.07.2018
      ABABCXYZ01.08.2018
      ABABCXYZ131.09.2018
      ABABCXYZ141.10.2018
      ABABCXYZ151.11.2018
      ABABCXYZ161.12.2018

       

      When I select a month on date slicer in my visual. Which [Dep Airport Code] is open and what is these airport codes sum frequency by month.

       

      I hope this example make you clear thank you 

      • VahidDM's avatar
        VahidDM
        Icon for Super User rankSuper User

        akay23 

        How can find which [Dep Airport Code] is open? and how did you calculate the Frequency numbers in the result table:

         

        Can you add more details?

         


        Appreciate your Kudos!!
        LinkedIn: 
        www.linkedin.com/in/vahid-dm/