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

check if anything selected in Slicer, then do sum based on selected Slicer values

Hi,

 

I'm new to DAX and cannot find a solution to this problem I'm having.

I've come up with a Measure formula that is only partially working unfortuntely. 

 

I have a data table in my report:

Manager Activity CostCategory Year Month AnnualBudget 
JohnDoeIT80020231$250
JohnDoeIT90020231$50
JohnDoeIT80020232$250
JohnDoeIT90020232$50


I have four slicers that users select from:
Manager, Activity, Year, Month

I have measure that calculates Total of Annual budget based on those slicer selections and shows the Sum value on Card. 
For example, if I have Slicers selected like below:
Manager=JohnDoe, Activity=IT, Year=2023, Month=1, then my measure value would be $300 on the Card which is correct.

The problem I'm having is when a Month is NOT selected the Card shows $600 - the sum of all Months.
Since budget amount is set in the begining of year and doesnt change over month till end of year, I want it to sum only for single month, not all 12 months. 

What I would like:
- if nothing selected on Slicer, show message "Please select from criteria first" on the Card
- if only Slicer Manager, Activity are selected, show message "Please select a year also" on the Card
- if Slicer Manager, Activity, Year are selected, show $300 on the Card (the sum value of single month only)
- if all selected, show $300 on the Card

My measure code is only working correctly when Month is also selected, otherwise it's multiplying that amount which I dont want. 

 

 

FinalAnnualBudget = 
var ManagerSelected = SELECTEDVALUE(Expense[Manager], "")
var ActivitySelected = SELECTEDVALUE(Expense[Activity], "")
var YearSelected = SELECTEDVALUE(Expense[FISCAL_YEAR], "")
var val = IF(AND(NOT ISBLANK(ActivitySelected), NOT ISBLANK(YearSelected)), 
"$" & CONVERT(SUM(Expense[Annual_Budget]), STRING), "Please select from criteria first")
return val

 

 

Another issue I'm having is when I show the message "Please select from criteria first", it's not fitting inside the Card because the Card is formatted to show Currency. Is it possible to also format the message by making the text size smaller and change the color in Measure code or in some other way?

Thank you.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @powerbeye ,

 

Here are the steps you can follow:

1. Create measure.

Measure  =
SWITCH(
    TRUE(),
ISFILTERED('Table'[Manager])&&ISFILTERED('Table'[Activity])&&NOT(ISFILTERED('Table'[Year]))&&NOT(ISFILTERED('Table'[Month])) ,"Please select a year also",
ISFILTERED('Table'[Manager])&&ISFILTERED('Table'[Activity])&&ISFILTERED('Table'[Year])&&NOT(ISFILTERED('Table'[Month])),SUMX(FILTER(ALLSELECTED('Table'),'Table'[Month]=MAX('Table'[Month])),[AnnualBudget]),  ISFILTERED('Table'[Manager])&&ISFILTERED('Table'[Activity])&&ISFILTERED('Table'[Year])&&ISFILTERED('Table'[Month]),SUMX(ALLSELECTED('Table'),[AnnualBudget]),
    "Please select from criteria first"
   )

2. Result:

vyangliumsft_0-1698040131186.png

 

vyangliumsft_1-1698040131188.png

vyangliumsft_2-1698040180658.png

 

vyangliumsft_3-1698040180659.png

 

 

Best Regards,

Liu Yang

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

4 REPLIES 4

select = SWITCH(
    true(),
    ISFILTERED(buget[Manager])&&ISFILTERED(buget[activity])&&not(ISFILTERED(buget[year]))&&not(ISFILTERED(buget[Month]))," Please select year also ",
    ISFILTERED(buget[Manager])&&ISFILTERED(buget[activity])&&ISFILTERED(buget[year])&&NOT(ISFILTERED(buget[Month])),SUMX(FILTER(ALLSELECTED(buget),buget[Month]=MAX(buget[Month])),buget[annual buget ]),
    ISFILTERED(buget[Manager])&&ISFILTERED(buget[activity])&&ISFILTERED('buget'[year])&&ISFILTERED(buget[Month]),SUMX(ALLSELECTED(buget),[annual buget ]),
    "Please select from criteria first")
 
Anuja_Chaudhari_0-1706611447338.pngAnuja_Chaudhari_1-1706611523551.png

 

 
Anonymous
Not applicable

Hi  @powerbeye ,

 

Here are the steps you can follow:

1. Create measure.

Measure  =
SWITCH(
    TRUE(),
ISFILTERED('Table'[Manager])&&ISFILTERED('Table'[Activity])&&NOT(ISFILTERED('Table'[Year]))&&NOT(ISFILTERED('Table'[Month])) ,"Please select a year also",
ISFILTERED('Table'[Manager])&&ISFILTERED('Table'[Activity])&&ISFILTERED('Table'[Year])&&NOT(ISFILTERED('Table'[Month])),SUMX(FILTER(ALLSELECTED('Table'),'Table'[Month]=MAX('Table'[Month])),[AnnualBudget]),  ISFILTERED('Table'[Manager])&&ISFILTERED('Table'[Activity])&&ISFILTERED('Table'[Year])&&ISFILTERED('Table'[Month]),SUMX(ALLSELECTED('Table'),[AnnualBudget]),
    "Please select from criteria first"
   )

2. Result:

vyangliumsft_0-1698040131186.png

 

vyangliumsft_1-1698040131188.png

vyangliumsft_2-1698040180658.png

 

vyangliumsft_3-1698040180659.png

 

 

Best Regards,

Liu Yang

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

Can we show message "please select brand" inside Barchart and once the user selects Brand from filter  the message should be gone and the data should show.

Please suggest.

Thank you

ThxAlot
Super User
Super User

Try incoporating ISFILTERED() function into those criteria of your measure.



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



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!

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.