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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
gunicotra
Helper II
Helper II

slicer selected choice

Hi to all,

I am trying to change dynamically a measure coherently with the value of a year slicer, but this is not working properly.

I have a:

- Year slicer with the column of a Table1 "Table1[Year]" which may have two years 2020, 2021

- measure on a Table2 which should be dependent on that slicer. I have tryed with three different solutions:


Sol1: This is working.... but it is not dynamically dependent on the slicer!
CALCULATE(SUM(Table2[Counter]),
Table2[CODE]="10"||Table2[CODE]="11"||Table2[CODE]="12"||Table2[CODE]="13"||Table2[CODE]="14",
'Table2'[ANNO_CAMPAGNA] = 2020),

 

Sol2: This is not working. Even if the selectedvalue(Table1[YEAR]) is correctly 2020, the result I got, is all the data of 2020 and 2021, 
If(SELECTEDVALUE(Table1[YEAR])=2020,
      CALCULATE(SUM(Table2[Counter]),
      Table2[CODE]="10"||Table2[CODE]="11"||Table2[CODE]="12"||Table2[CODE]="13"||Table2[CODE]="14",
      'Table2'[YEAR] = 2020),

      CALCULATE(SUM(Table2[Counter]),
      Table2[CODE]="10"||Table2[CODE]="11"||Table2[CODE]="12"||Table2[CODE]="13"||Table2[CODE]="14",
      'Table2'[YEAR] = 2021),


Sol3: This is partially working. For some reason it gives me "some" data of 2020 (not all of them!) and none of those of 2021.
CALCULATE(SUM(Table2[Counter]),
Table2[CODE]="10"||Table2[CODE]="11"||Table2[CODE]="12"||Table2[CODE]="13"||Table2[CODE]="14",
FILTER(Table2, Table2'[YEAR] IN VALUES Table1[YEAR]),

Any hints?

Thanks in advance!!
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@gunicotra , This kind of measure is suitable if table 1 and table 2 are not connected

 

measure =
var _year = allselected(Table[Year])
return
CALCULATE(SUM(Table2[Counter]),filter(Table2 , Table2[CODE] in {"10", "11", "12","13","14"} && 'Table2'[YEAR] in _year))

 

because if they are connected , it will already have filter impact

 

I explained it here

Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@gunicotra , This kind of measure is suitable if table 1 and table 2 are not connected

 

measure =
var _year = allselected(Table[Year])
return
CALCULATE(SUM(Table2[Counter]),filter(Table2 , Table2[CODE] in {"10", "11", "12","13","14"} && 'Table2'[YEAR] in _year))

 

because if they are connected , it will already have filter impact

 

I explained it here

Need of an Independent Table in Power BI: https://youtu.be/lOEW-YUrAbE

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

great solution!  it works perfectly. Thanks 🙂

gunicotra
Helper II
Helper II

N.B.: "ANNO_CAMPAGNA" means "YEAR"

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.