Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello,
Sorry if i ask beginner questions. I hope someone can help me. Here is my dax measure formula :
Vert1 = CALCULATE(
VAR AA = SUMX('Lot 1','Lot 1'[Xp]-'Lot 1'[Prérequis])
VAR BB = IF (AA<0,0,1)
VAR CC = IF(BB>=2,2,BB)
RETURN CC
,Code[Color]="V")
I don't understand why I have values in my bar chart over 2 whereas i ask to put 2 if my variable goes over 2 . My bar chart is based on 2 other columns value. One column for C1 for competencies and the other C2 C2 is in absciss.
Thanks for your help
Hello @Anonymous
First of all, I also can't explain why this measure would ever return a number other than 0, 1 or 2.
It does look like you intended to write VAR CC slightly differently:
VAR CC = IF(AA>=2,2,BB)
Though that still doesn't explain why you are getting results > 2.
I would recommend something like this instead. It puts all the conditions in a single SWITCH function:
Vert1 =
CALCULATE (
VAR AA =
SUMX ( 'Lot 1', 'Lot 1'[Xp] - 'Lot 1'[Prérequis] )
RETURN
SWITCH ( TRUE (), AA < 0, 0, AA < 1, 1, 2 ),
Code[Color] = "V"
)
Does this give the expected result?
Regards
Owen
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
11 | |
10 | |
10 | |
10 |
User | Count |
---|---|
16 | |
13 | |
12 | |
11 | |
8 |