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.
hi all
coming from a python background, i am trying to get the hang of dax.
however I am having trouble with the following attempt:
Solved! Go to Solution.
Hi, @fisqkuz1
Try measure formula like the following:
Measure =
var _col=MAX('Table'[col])
var _col2=MAX('Table'[col2])
return
SWITCH(TRUE(),
_col="short"&&_col2>0,2,
_col="short"&&_col2<>0,1,
_col="long"&&_col2>0,1,
_col="long"&&_col2<>0,2,
2
)
If it doesn't work, pelase share your sample data and expected result in excel.
Best Regards,
Community Support Team _ Eason
Hi, @fisqkuz1
Try measure formula like the following:
Measure =
var _col=MAX('Table'[col])
var _col2=MAX('Table'[col2])
return
SWITCH(TRUE(),
_col="short"&&_col2>0,2,
_col="short"&&_col2<>0,1,
_col="long"&&_col2>0,1,
_col="long"&&_col2<>0,2,
2
)
If it doesn't work, pelase share your sample data and expected result in excel.
Best Regards,
Community Support Team _ Eason
Hi @fisqkuz1
I don't fully understand your If - Else statement but you may try the following
Revenue or Cost =
SUMX (
table,
IF (
table[col] = "short" & table[col2] > 0,
2,
IF ( table[col] = "long" & table[col2] > 0, 1, 2 )
)
)
hi, thanks for your answer!
i want to simply get a 1 or 2 as output such as booleans
where 1 = revenue and 2 = cost
The you use the sane logic. Only last oart shall not be required
Revenue or Cost =
SUMX (
table,
IF (
table[col] = "short" & table[col2] > 0,
table[Revenue],
IF ( table[col] = "long" & table[col2] > 0, table[Cost] )
)
)
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 |
---|---|
10 | |
9 | |
8 | |
7 | |
6 |
User | Count |
---|---|
14 | |
13 | |
11 | |
9 | |
8 |