Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

PowerBI Dax - Display row based on certain condition

I got two filter (Company Name & Vessel Name) and one table as below; I got three condition to fulfil

 

 

First one, if company name and vessel name filter is selected at same time, table will show detail with status FALSE, As example, Jimmy and Ali Anca shown with fail status

 

Second condition is, if only vessel filter is selected, table will show detail with only TRUE status. As example, when Ali Anca is selected, table show Ali Anca with TRUE status;

 

 

Third condition is, when both filter is not selected, All data will be shown on table with only TRUE status as below;

 

Really appreciate if anyone can help

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Anonymous ,

     

    You will need to create two independent table as below and use these two tables as slicers.

     

    Company = DISTINCT('Table'[Company Name])
    
    Vessel = DISTINCT('Table'[Vessel Name])

    Then create a measure as below and add it to visual filter set value = 1.

    Measure = 
    var T_company = SELECTEDVALUE('Table'[Company Name])
    var T_vessel = SELECTEDVALUE('Table'[Vessel Name])
    var C_company = SELECTEDVALUE(Company[Company Name])
    var V_vessel = SELECTEDVALUE(Vessel[Vessel Name])
    var T_status = SELECTEDVALUE('Table'[Status])
    return
    SWITCH(TRUE(),
        ISFILTERED(Company[Company Name])&&ISFILTERED(Vessel[Vessel Name]),
            IF(T_company=C_company&&T_vessel=V_vessel&&T_status="FALSE",1,0),
        NOT(ISFILTERED(Company[Company Name]))&&ISFILTERED(Vessel[Vessel Name]),
            IF(T_vessel=V_vessel&&T_status="TRUE",1,0),
        NOT(ISFILTERED(Company[Company Name]))&&NOT(ISFILTERED(Vessel[Vessel Name])),
            IF(T_status="TRUE",1,0))

     

    Best Regards,

    Jay

4 Replies

  • Anonymous ,isfiltered can help

    Try a measure like

    measure =
    Switch( true() ,
    isfiltered(Table[Companyname]) && isfiltered(Table[VessalName]) , calculate(countrows(Table) , filter(Table, Table[Status] = FALSE())),
    isfiltered(Table[Companyname]) && isfiltered(Table[VessalName]) , calculate(countrows(Table) , filter(Table, Table[Status] = TRUE()))
    )

    • Anonymous's avatar
      Anonymous
      Not applicable

      Should this measure place on visual filter (table)?

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

        Anonymous , it can be placed with all un summarized columns, then it will filter data. If there is any other measure you can also use it as a visual level filter

         

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    You will need to create two independent table as below and use these two tables as slicers.

     

    Company = DISTINCT('Table'[Company Name])
    
    Vessel = DISTINCT('Table'[Vessel Name])

    Then create a measure as below and add it to visual filter set value = 1.

    Measure = 
    var T_company = SELECTEDVALUE('Table'[Company Name])
    var T_vessel = SELECTEDVALUE('Table'[Vessel Name])
    var C_company = SELECTEDVALUE(Company[Company Name])
    var V_vessel = SELECTEDVALUE(Vessel[Vessel Name])
    var T_status = SELECTEDVALUE('Table'[Status])
    return
    SWITCH(TRUE(),
        ISFILTERED(Company[Company Name])&&ISFILTERED(Vessel[Vessel Name]),
            IF(T_company=C_company&&T_vessel=V_vessel&&T_status="FALSE",1,0),
        NOT(ISFILTERED(Company[Company Name]))&&ISFILTERED(Vessel[Vessel Name]),
            IF(T_vessel=V_vessel&&T_status="TRUE",1,0),
        NOT(ISFILTERED(Company[Company Name]))&&NOT(ISFILTERED(Vessel[Vessel Name])),
            IF(T_status="TRUE",1,0))

     

    Best Regards,

    Jay