Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
hello i'm trying to translate this python code into dax using variable
def force(p😞 if p["Zones_A"] == "4" and p["Zone_C"] == "4": return p["net"] elif p["Zones_A"] == "4" and p["Zone_C"] == "3": return p["CA_fid_CRF"]*mvt["Effet"][mvt["Mvt"]=="B-C"] elif p["Zones_futures"] == "4" and p["Zone_future_ap_reco"] == "2": return p["CA_fid_CRF"]*mvt["Effet"][mvt["Mvt"]=="B-D"] elif p["Zones_futures"] == "4" and p["Zone_future_ap_reco"] == "1": return p["CA_fid_CRF"]*mvt["Effet"][mvt["Mvt"]=="B-E"] elif p["Zones_futures"] == "4" and p["Zone_future_ap_reco"] == "0": return p["CA_fid_CRF"]*mvt["Effet"][mvt["Mvt"]=="B-NA"] elif p["Zones_futures"] == "3" and p["Zone_future_ap_reco"] == "4": return p["CA_fid_CRF"]*mvt["Effet"][mvt["Mvt"]=="C-B"] elif p["Zones_futures"] == "3" and p["Zone_future_ap_reco"] == "3": return p["gain_net"]
and what i'm trying to do with dax
Solved! Go to Solution.
@Anonymous , You need to try Switch(True(),
example
SWITCH(true(),
search("Red",[column1],1,0)>0 || search("Green",[column1],1,0)>0 ,"C1"
search("Yellow",[column1],1,0)<0 , "C1",
blank()
)
Also, it can only one data type. so take care of that
@Anonymous , You need to try Switch(True(),
example
SWITCH(true(),
search("Red",[column1],1,0)>0 || search("Green",[column1],1,0)>0 ,"C1"
search("Yellow",[column1],1,0)<0 , "C1",
blank()
)
Also, it can only one data type. so take care of that
Please see this post on SWITCH(TRUE(), ... which would be best approach for your scenario.
https://powerpivotpro.com/2015/03/the-diabolical-genius-of-switch-true/
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Check out the February 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 61 | |
| 59 | |
| 42 | |
| 18 | |
| 15 |
| User | Count |
|---|---|
| 108 | |
| 100 | |
| 39 | |
| 29 | |
| 29 |