Forum Discussion

IwanVB's avatar
IwanVB
Frequent Visitor
2 years ago

Always show certain data in a Graph despite slicer selection

I have the situation where in one table both Savings and Targets are stored (data structure below). I want to have a graph with on the x-axis the years, and on the y-axis the Savings (bar) Target (line).


The solution I have in mind is:

- Two slicers: one for "BG", one for "Plant"

- The result (table or graph)  should always display the target records despite the value of the slicer. 

 

Data Structure

BG        | Plant    | Saving | Target | year

------------------------------------

A1        |  B1       |   200   |     0     | 2023

A 2       |  B2       |   200   |     0     | 2024

etc.

Target  |  Target  |   0      |    105   | 2023

Target  |  Target  |   0      |    205   | 2024

 

What I did already

 

First, for the slicers I made a separate table using DAX storing the BG and Plant. This table (called "Table1") has no relation with my main table 

category list =
SELECTCOLUMNS(
    Table1,
    "BG",Table1[BG]"Plant",Table1[Plant]
)

Second: Added a measure to my main table. If the value for the plant record is "Target" the 1 otherwise 0. This this for both the "Plant" and "BG" field. 

is filter_plant =
if(
    MIN(Table1[Plant]) = "Target" ,
    1,
    if (
        MIN(Table1[Plant]IN VALUES('category list'[Plant]) ,
        1,
        0
    )

Result
In the slicer (via category list), "BG=A2", the the table looks like below. Which is acutally great, since now I can filter on "filter_plant=1" and "filter_bg=1" and the table will show the perfect and desired result

BG        | Plant    | Saving | Target | year | filter_plant | filter_bg

--------------------------------------------------------------------

A1        |  B1       |   200   |     0     | 2023  |   0             |  0

A 2       |  B2       |   200   |     0     | 2024  |   1             |  1

etc.

Target  |  Target  |   0      |    105   | 2023 |    1             |  1

Target  |  Target  |   0      |    205   | 2024 |   1             |  1


The problem
When i create a "line and clustered column chart" out of the table above, the result is good when no data is selected via the slicer. Once selected via the slicer, the graph is empty. How to solve?

1 Reply

  • IwanVB , Try like

     

    Countrows(filter(Table1, Table1[Plant] IN VALUES('category list'[Plant]) || Table1[Plant] = "Target"))+0

     

     

    or

     

    Switch(True(),
    max(Table1[Plant]) IN VALUES('category list'[Plant]) || max(Table1[Plant]) = "Target", 1,0)+0