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
yousef_alsalem
New Member

Getting selected Month from a slicer

Hi,
I have issue with getting the selected value from a drop down list slicer.
I have a mesure in the Months table to catch the select value in the slicer

SelectedMonth = SELECTEDVALUE('Months'[MonthName])
 
I want to count the joiners in Joiners table > EmpCount and list them in a table


But this is not working
 
EmpCount =
var mon = Months[SelectedMonth]  //  VALUE('Months'[SelectedMonth]) //  VALUES(Months[MonthName]) All not working
VAR data =
    CALCULATE(
        COUNT(MainData[Employee Id]),
        FILTER(
            MainData,
            MainData[Business Unit] = Joiners[Business Unit] &&
            MainData[Hiring Month] = mon
        )
    )
RETURN data
yousef_alsalem_0-1704866896944.png
 

To test the code, this is working

 

EmpCount =
 
 
VAR data =
    CALCULATE(
        COUNT(MainData[Employee Id]),
        FILTER(
            MainData,
            MainData[Business Unit] = Joiners[Business Unit] &&
            MainData[Hiring Month] = "December"
        )
    )
RETURN data

 yousef_alsalem_2-1704867531697.png

 

Please help me with this.

File : Turnover_dummy.pbix 
1 ACCEPTED SOLUTION

Did you create a measure? From your file: 

ERD_0-1704876418318.png

Your screenshot shows a summarized column, not a measure.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

10 REPLIES 10
Fowmy
Super User
Super User

@yousef_alsalem 

Have you created the required relationship between the tables?

Sharing a dummy Power BI file representing your scenario would be beneficial. You can save the Power BI file on Google Drive or any other cloud storage platform and provide the link here. Kindly ensure that permission is granted to open the file.


Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Hi,

Linking the table in a relationship is not what I want, because this is part of a bigger project and some tables have no realtions. In the next step I will have to add more filter, like by year and quarter etc.

I have added a dummy file at the end of my post.

 

Thank you

ERD
Community Champion
Community Champion

Hi @yousef_alsalem ,

- make sure you use 'Months'[MonthName] in the slicer

- try rewrite the measure:

 

EmpCount =
var mon = SELECTEDVALUE('Months'[MonthName])
VAR data =
    CALCULATE(
        COUNT(MainData[Employee Id]),
        MainData[Business Unit] = Joiners[Business Unit],
        MainData[Hiring Month] = mon
    )
RETURN data

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Thanks for the reply but it give me an error, cannot find name Business Unit

The expression contains columns from multiple tables, but only columns from a single table can be used in a True/False expression that is used as a table filter expression.


I'm sure that I use 'Months'[MonthName] in the slicer
I belive that my code main issue in getting the selected value from the slicer not filtring the data.

Oh, sorry, indeed, it will give an error since it's a measure. Try this:

EmpCount =
var mon = SELECTEDVALUE('Months'[MonthName])
VAR data =
    CALCULATE(
        COUNT(MainData[Employee Id]),
        MainData[Business Unit] = SELECTEDVALUE(Joiners[Business Unit]),
        MainData[Hiring Month] = mon
    )
RETURN data

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Theres is no slice for the business unit.
In the next step I will have to add more filters, like by year and quarter etc.

I have added a dummy file at the end of my post.

Actually there is, and you can see it on your screenshot:

ERD_0-1704875448902.png

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

It gives no result

:1023034i5BA7A9B07F2833B1:

yousef_alsalem_1-1704876064694.png

 

 

Did you create a measure? From your file: 

ERD_0-1704876418318.png

Your screenshot shows a summarized column, not a measure.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly. Appreciate your Kudos.

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Thank you it's working now

 

EmpCountMeasure =
var selectedMonth = SELECTEDVALUE('Months'[MonthName])
var selectedYearSELECTEDVALUE('Years'[Year])

var data =
    CALCULATE(
        COUNT(MainData[Employee Id]),
        MainData[Business Unit] = SELECTEDVALUE(Joiners[Business Unit]),
        MainData[Hiring Month] = selectedMonth,
        MainData[Hiring Year]= selectedYear
    )
RETURN data



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