Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
IwanVB
Frequent Visitor

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 1
amitchandak
Super User
Super User

@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

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.