The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
I created this measure to calculate accounts that are above a spend threshold or return a blank value
Solved! Go to Solution.
The SUMX part you need. I think I may have mixed up row context and filter context effects.
Try using just the row context:
SUMX (
DISTINCT ( 'Actual Spend'[Account] ),
VAR SelectedItem = 'Actual Spend'[Account]
RETURN
SWITCH (
TRUE (),
SELECTEDITEM = "1 DIR LA HOURLY FRINGE", BLANK(),
SELECTEDITEM = "1 DIR LA HOURLY WAGES", BLANK(),
SELECTEDITEM = "1 DIR LA LESS: INTERNAL ORDERS", BLANK(),
[...et cetera...]
)
)
Still not totaling. Thanks for the blank tip - I'm pretty new to PowerBI and hadn't heard of that one yet. I even switched out the blank for 0 and it still didn't put a total column. Also tried creating a new visual in case I had somehow done something to my current one. Verified total is on for all columns and still no total...
The SUMX part you need. I think I may have mixed up row context and filter context effects.
Try using just the row context:
SUMX (
DISTINCT ( 'Actual Spend'[Account] ),
VAR SelectedItem = 'Actual Spend'[Account]
RETURN
SWITCH (
TRUE (),
SELECTEDITEM = "1 DIR LA HOURLY FRINGE", BLANK(),
SELECTEDITEM = "1 DIR LA HOURLY WAGES", BLANK(),
SELECTEDITEM = "1 DIR LA LESS: INTERNAL ORDERS", BLANK(),
[...et cetera...]
)
)
That worked. I never in a million years would have known or stumbled on that. Thank you!
At the total level, SELECTEDVALUE returns a blank because there is no single account. Thus the measure returns a blank in this filter context.
To sum across acounts, you need to actually do a sum. Try wrapping the whole thing with SUMX
SUMX (
DISTINCT ( 'Actual Spend'[Account] ),
VAR SelectedItem = SELECTEDVALUE ( 'Actual Spend'[Account] )
RETURN
SWITCH (
TRUE (),
SELECTEDITEM = "1 DIR LA HOURLY FRINGE", BLANK(),
SELECTEDITEM = "1 DIR LA HOURLY WAGES", BLANK(),
SELECTEDITEM = "1 DIR LA LESS: INTERNAL ORDERS", BLANK(),
[...et cetera...]
)
)
(Note: I'm using blanks instead of " ".)