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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ChristianHE
Frequent Visitor

Using Variables as filters

Hi community

 

I am having a little trouble understanding how to use variables, i have made the following formula:

 

Test = 

Var Rep = VALUES(Kundetabel[Repræsentant])
Var Kunde = VALUES(Kundetabel[KUNDENRNAVN])
 
return
CALCULATE([Potientiale];
TOPN(10;
CALCULATETABLE(all(Kundetabel);
FILTER(Kundetabel; Kundetabel[Repræsentant] in Rep)
)
;[Potientiale];ASC)
;Rep; Kunde
)
 
I was hoping my calculatetable would give me a table consisting only of the chosen "Repræsentant", but i suspect it does not. Can someone explain me how it works, alternately see what is wrong with my formula?
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@ChristianHE , Try like

 

Test = CALCULATE([Potientiale];TOPN(10,allselected(Kundetabel);[Potientiale],ASC),VALUES(Kundetabel[KUNDENRNAVN]))

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

View solution in original post

@ChristianHE , better have to measure with filter sales >1, if it line level. If it after grouping then use values 

 

sumx(Filter(values(Table[Col1]),[sales]>1),[Sales])

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

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@ChristianHE , Try like

 

Test = CALCULATE([Potientiale];TOPN(10,allselected(Kundetabel);[Potientiale],ASC),VALUES(Kundetabel[KUNDENRNAVN]))

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  it works, Thank you very much.

 

If i wanted to add more filters to my [Kundetabel], for example if i only wanted to see customers with a sales above 1.  Would that be possible to add in the formula or should it be added in the "Filters"-pane?

@ChristianHE , better have to measure with filter sales >1, if it line level. If it after grouping then use values 

 

sumx(Filter(values(Table[Col1]),[sales]>1),[Sales])

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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