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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
AnnaMagnusson
Helper I
Helper I

Why does slicer value have to be selected for measure to work?

Hi!

 

I have two slicers for a line chart; 1 is for the machine I'm looking at och 2 is for the machines I compare with.

If I select A in 1, the measure I'm using in a line chart only works when I have any combination with A eg. A+B, A+C etc. in 2. I have tried using all(), removefilters() and others but not sure what to do.. Is there something in the code that is wrong?

 

(I can't remove the interaction since then other measures get messed up)

 

slicer 1 is dim_machine[name]
slicer 2 is dim_machine_comp[name]

 

comp straight =
var s = ALLSELECTED(Dim_Machine_Comp[Name])
VAR CurrentDay = SELECTEDVALUE(Fact_IntDay[DateDay])

VAR PrevDate = CALCULATE(MAX(Fact_IntDay[DateDay]), all(Dim_Machine[Name]), FILTER(Dim_Machine_Comp, Dim_Machine_Comp[Name] in s ) , and(Fact_IntDay[Moving Average] <> BLANK() , Fact_IntDay[DateDay] < CurrentDay ))
VAR NextDate = CALCULATE(MIN(Fact_IntDay[DateDay]), all(Dim_Machine[Name]), FILTER(Dim_Machine_Comp, Dim_Machine_Comp[Name] in s ), and( FactIntDay[Moving Average] <> BLANK() , Fact_IntDay[DateDay] > CurrentDay ))

VAR Gap = calculate(value(NextDate - PrevDate))
VAR CurrentDiff = calculate(value(currentday - PrevDate))

VAR PrevD = CALCULATE(AVERAGE(Fact_IntDay[Moving Average]), all(Dim_Machine[Name]), FILTER(Dim_Machine_Comp, Dim_Machine_Comp[Name] in s), Fact_IntDay[DateDay] = PrevDate)
VAR NextD = CALCULATE(AVERAGE(Fact_IntDay[Moving Average]), all(Dim_Machine[Name]), FILTER(Dim_Machine_Comp, Dim_Machine_Comp[Name] in s), Fact_IntDay[DateDay] = NextDate)
VAR OutputValue = calculate(PrevD + ( Divide(NextD - PrevD , Gap) * CurrentDiff ), all(Dim_Machine[Name]), FILTER(Dim_Machine_Comp, Dim_Machine_Comp[Name] in s))

return
calculate(if(isblank([Comp]),
    SWITCH( TRUE(),
           ISINSCOPE(Fact_IntDay[DateDay]), OutputValue, [comp comb hour straight lines]),
[Comp]),
REMOVEFILTERS(Dim_Machine[Name]))
 
where 
 
Comp =
var s = ALLSELECTED(Dim_Machine_Comp[Name])
var d = CALCULATE(AVERAGE(Fact_IntDay[Moving Average]), all(Dim_Machine[Name]), FILTER(Dim_Machine_Comp, Dim_Machine_Comp[Name] in s ), REMOVEFILTERS(Dim_Machine[Name]))
var h = CALCULATE(AVERAGE(Fact_IntHour[Moving Average]), all(Dim_Machine[Name]), FILTER(Dim_Machine_Comp, Dim_Machine_Comp[Name] in s ), REMOVEFILTERS(Dim_Machine[Name]))
 
return
SWITCH( TRUE(),
       ISINSCOPE(Fact_IntDay[DateDay]), d, h)
2 REPLIES 2
amitchandak
Super User
Super User

@AnnaMagnusson  Not very clear on you issue. But date has moved to date table connected or independent based on need as you are using >= independent might work well

 

I am assuming Dim_Machine_Comp is joined with fact

 

refer if needed

Compare two Brands: https://youtu.be/exN4nTewgbc

Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak I'll try to be more specific.

So I have a line chart where I want to compare values between one machine (A) and all machines (A to D), the values are from the measure comp. The dates where I don't have values I interpolate, that's the measure comp straight

If I select A in the first slicer och A, B and C in the second one, I see the measure comp straight. But if I don't select A I get an average of the values from B and C, which is not equal to the value from comp straight. I thought I could remove the slicer/filter context by using all or removefilter but that is not working. Is there another way? How do I get the red line without having to select A?

 

The grey dotted line is the average and the red dashed line is comp straight .

11.JPG12.JPG

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors