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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PSampras
Frequent Visitor

Use slicer value to filter a table

Hy everyone,

this is my first post here 😃 I hope to write it in the right way

 

This is my problem.

I have a simple "Table 1 - Fatturato"

 

PSampras_0-1659021455730.png

 

I want to create an other table "Table 2 - Fatturato progressivo" containing only first n months of the year.
I create a calculatetable, named TbProgressivo, and i got it.

TbProgressivo = CALCULATETABLE(FACT_PL_FATTURATO,year(FACT_PL_FATTURATO[DatDoc])=2022 && month(FACT_PL_FATTURATO[DatDoc])<=3)

PSampras_1-1659021556054.png

This is the result i want.

But i got it inserting manually 2022 as year and 3 as month.

I want to read these 2 values (year and month) from respective slicers

 

PSampras_2-1659022465333.png

 

With this measure, i can read the slicer value

 

MeseSelezionato = SELECTEDVALUE(CALENDARIO[MonthOfYear])

 

PSampras_3-1659022627072.png

 

But when i use it in calculatetable

 

TbProgressivo = CALCULATETABLE(FACT_PL_FATTURATO,year(FACT_PL_FATTURATO[DatDoc])=2022 && month(FACT_PL_FATTURATO[DatDoc])<=SELECTEDVALUE(CALENDARIO[MonthOfYear]))

Result is a empty table

PSampras_4-1659022811153.png

 

I think this a relation problem or some issue with calendar table.

But i can't figure out...

 

This is the relations:

PSampras_5-1659022956618.png

 

File pbix: https://drive.google.com/file/d/1inh92l7sQzFfXJYuu6D2scuRlvPoJWTK/view?usp=sharing

 

Thanks for the help!!

Giuseppe



 

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @PSampras ,

 

To my knowledge, calculated table could not be dynamically changed via slicer.

 

If you want to dynamically filter a table... I‘d suggest you put the columns into a table visual and create a measure that will return 1 for the rows you want to see and 0 for those that you don't. Then use the Visual-level Filter Pane to filter the rows by the measure. For example:

Flag Filter = IF(YEAR(MAX('Fatturato'[DatDoc]))=SELECTEDVALUE('Year Selection'[Year]) && MONTH(MAX('Fatturato'[DatDoc]))<=SELECTEDVALUE('Month Selection'[Month]),1,0)

Eyelyn9_1-1659495906792.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
v-eqin-msft
Community Support
Community Support

Hi @PSampras ,

 

To my knowledge, calculated table could not be dynamically changed via slicer.

 

If you want to dynamically filter a table... I‘d suggest you put the columns into a table visual and create a measure that will return 1 for the rows you want to see and 0 for those that you don't. Then use the Visual-level Filter Pane to filter the rows by the measure. For example:

Flag Filter = IF(YEAR(MAX('Fatturato'[DatDoc]))=SELECTEDVALUE('Year Selection'[Year]) && MONTH(MAX('Fatturato'[DatDoc]))<=SELECTEDVALUE('Month Selection'[Month]),1,0)

Eyelyn9_1-1659495906792.png

 

Best Regards,
Eyelyn Qin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you @v-eqin-msft , it works!

amitchandak
Super User
Super User

@PSampras , if you select one month and want to display more than that then your slicer need to be on an independent date table

 

example

 

//Date1 is independent Date table, Date is joined with Table
new measure =
var _max = maxx(allselected(Date1),Date1[Date])
var _min = eomonth(_max, -1 *month(_max) ) +1
return
calculate( sum(Table[Value]), filter('Date', 'Date'[Date] >=_min && 'Date'[Date] <=_max))

 

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

I need to create a relation between Date and Date1?
Thank for your reply and your support.

@amitchandak 
Your formula works great: using CALENDARIO2 as indipendent data table, i obtain the progressive value related to the month selected in slicer ("Fatturato progressivo").
6.632.458,12 is the sum of gen, feb and mar. Cool!

PSampras_0-1659123021658.png

 

But i can't understand how to use your kindly advice to obtain a table like this (Table2 in the figure)

PSampras_1-1659123365814.png


I use:

Table2 =
CALCULATETABLE(FACT_PL_FATTURATO,CALENDARIO[Year]="2022" && CALENDARIO[MonthOfYear]<4)


and it works but, obviously, i have to replace 2022 and 4 with slicers values.

Thank you,
Giuseppe

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.