Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hello. Pardon the ignorance embedded in this question, but I am trying to put together a proof of concept report and I have a measure that is critical. I believe DAX can compute this but as yet I lack the depth to troubleshoot the logic and/or syntax issues I am having with this measure.
I have a fact table (CFNDFact) that has columns for chart of account fields and a single value row called "data". I need a measure that, based on the value of the "ACCOUNT" field (of which there are only four), will return either 0, the value of [data], or the negative of [data]. I want this measure computed for each row and the summary groupings to be handled by the visualizations.
I am sure it is just my ignorance of some basic DAX that is making this much harder than it is. I hope one of you experienced people can spare a couple minutes to point out what I don't get yet. Thanks for your help.
A couple things I have tried are:
County Funding = SWITCH([Account],
"INTREV",0,
"NONOPREV",0,
"OPREV",-[data],
"TOTEXP",[data],0)
County Funding =
IF ([ACCOUNT]="INTREV",0,
IF ([ACCOUNT]="NONOPREV",0,
IF ([ACCOUNT]="TOTEXP",[data],
IF ([ACCOUNT]="OPREV",-[data],))))
Hi @uBoatCaptain,
Can you post sample data on which you are trying to apply the formulas ?
Thanks
Achin
Here is an example of the data. This is the fact table, and every column except 'data' has a related dimension table.
column | fund | dept_id | ACCOUNT | program | req_item | data |
ADOPTED | 230 | 1015000100 | TOTEXP | 0 | 0 | 1053817 |
ADOPTED | 230 | 1015000100 | TOTEXP | 0 | 101500_01 | 20000 |
ADOPTED | 230 | 1015000100 | TOTEXP | 0 | 101500_02 | 0 |
ADOPTED | 230 | 1015000100 | TOTEXP | 0 | 101500_03 | 5000 |
ADOPTED | 230 | 1015000100 | TOTEXP | 0 | 101500_05 | 5000 |
I attempted to see if I could create this as a column and it worked. I simplified the formula in the process to County Funding = SWITCH(CFNDFact[ACCOUNT],"TOTEXP",[data],"OPREV", -[data],0).
Trying to use this same formula (with a different measure name) for a measure gets the error
'A single value for column 'data' in table 'CFNDFact' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.'
@uBoatCaptain - Glad you got it working. Yep, that was what I figured was going on and the exact error that I would have expected you to get with that formula used in a measure. Basically, a measure has to use an aggregation function because its context is dynamic within a report depending upon filters, slicers and the visualizations themselves that they are used within. Therefore, you can't single out any particular thing with a measure, measures always assume that they are dealing with a "set" of things. Always think of measures as if you have to feed it a "table" of things (multiple rows). Calculated columns on the other hand are constrained to their row context (more or less) and so you can grab individual values in that row or a related row in another table.
Sounds like this should be a column really rather than a measure potentially. And I'm not sure of the logic for summary groupings honestly. What is the problem you are running into? Syntax error or something else?
User | Count |
---|---|
136 | |
70 | |
69 | |
54 | |
53 |
User | Count |
---|---|
207 | |
94 | |
64 | |
61 | |
57 |