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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Harrisfil
Helper I
Helper I

Dynamic filter and dynamic column measure

hello ,

 

I have the following issue. I have a small table:

 

TopNMeasureADate
Greece101/5/2024
Spain156/8/2024
Singapore2215/7/2024
Jamaica471/4/20243

what i  need is to create a parameter filter where i will filter this table per Top2 or Top3

 

and i need this table to be changed as follows: 

 

if i select top 2 then i need to see the top 2 countries perYtd and an extra row named " RestofCountries" with the rest total of other unfiltered countries. Any idea? thank you

 

TopNMeasureADate
Singapore2215/7/2024
Jamaica471/4/20243
RestOfcountries25 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Harrisfil ,

 

You can create a new slicer, use the date in the Table as the slicer field, and then modify the formula and use ALLSELECTED function:

vlinhuizhmsft_0-1727425180849.png

 

Best Regards,
Zhu
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Harrisfil ,

I created simple data:

vlinhuizhmsft_0-1727338015351.png

 

Please follow the steps:

1.In Power Query, click "Reference" and remove columns:

vlinhuizhmsft_1-1727338105505.png

 

vlinhuizhmsft_2-1727338187149.png

 

2.Add a step and close Power Query Editor:

 

= Table.Distinct( Table.InsertRows( #"Removed Columns",1,{[TopN="RestOfcountries"]}))

 

vlinhuizhmsft_3-1727338236527.png

 

3.Create a replationship:

vlinhuizhmsft_0-1727339383720.png

 

4.Create a measure:

 

Measure2 = 
VAR _table = TOPN(SELECTEDVALUE(Parameter[Parameter]),SUMMARIZE(ALL('Table'),'Table'[TopN],'Table'[Date],"Sales",[Measure]),[Sales])
VAR _top_country = SELECTCOLUMNS(_table,'Table'[TopN])
VAR _other_country = EXCEPT(ALL('Table'[TopN]),_top_country)
VAR _other_country_sales = SUMX(FILTER(ALL('Table'),'Table'[TopN] in _other_country),'Table'[Sales])
RETURN SWITCH(TRUE(),
    SELECTEDVALUE('Table (2)'[TopN]) IN _top_country,MAXX(FILTER(_table,'Table'[TopN]=SELECTEDVALUE('Table (2)'[TopN])),[Sales]),
    SELECTEDVALUE('Table (2)'[TopN]) = "RestOfcountries",_other_country_sales

)

 

 

5.The result is as follows:

vlinhuizhmsft_4-1727338391312.png

vlinhuizhmsft_5-1727338402111.png

 

Best Regards,
Zhu
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

Thank you very much for your time on that! Indeed its working great 🙂 Can i somehow add a date filter as well? so i can have both parameter and date filter in my model.

 

thank you again

Anonymous
Not applicable

Hi @Harrisfil ,

 

You can create a new slicer, use the date in the Table as the slicer field, and then modify the formula and use ALLSELECTED function:

vlinhuizhmsft_0-1727425180849.png

 

Best Regards,
Zhu
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.

great thank you very much ! its working great.

something last : can i always  set Rest of countries row in the end of the matrxi table ? i need first to sort it by the measure2 but i need this specific one to be sorted in the end indepedently of the measure asc/desc sorting in the table

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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
Top Kudoed Authors