Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
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 |
JohnDoe | IT | 800 | 2023 | 1 | $250 |
JohnDoe | IT | 900 | 2023 | 1 | $50 |
JohnDoe | IT | 800 | 2023 | 2 | $250 |
JohnDoe | IT | 900 | 2023 | 2 | $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.
Solved! Go to Solution.
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:
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
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:
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
Try incoporating ISFILTERED() function into those criteria of your measure.
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LeanAndPractise(Everyday) ) |
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
18 | |
15 | |
12 | |
11 | |
8 |
User | Count |
---|---|
24 | |
19 | |
12 | |
11 | |
10 |