Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi
I'm trying to create a TotalHours measure in my Model that is connected to OCLG table in SAP Business One. In this table that store the activities exist the DurType Field which values are 'H', 'M' or 'D'.
In my SQL sentences, I use this: select sum (case when DurType='M' then Duration/60 else Duration end) from OCLG
And Now I want to translate this to DAX. But when I write this
TotalHoras = SWITCH(Horas[DurType],'M',Horas[Duration]/60,'H',Horas[Duration])
I have error: Cannot find table 'M'
But If I use IF I have error too
TotalHoras = IF([DurType]='M',[Duration]/60,[Duration])
Any idea, please?
regards
Solved! Go to Solution.
Hi
The probem in measures is that they need an aggregation to works:
This works to me now:
TotalHoras = SUMX(Horas;if(Horas[Tipo]="M";Horas[Duration]/60;Horas[Duration]))
Thanks
Hi @kintela,
Based on my understanding, you want to add a conditional column using DAX, right?
If so, I would suggest you create a calculated column rather than measure. To reslove the error, you should modify the DAX formula as below:
TotalHoras = SWITCH(Horas[DurType],"M",Horas[Duration]/60,"H",Horas[Duration])
Please pay attention to the double quote.
Thanks,
Yuliana Gu
Hi
The probem in measures is that they need an aggregation to works:
This works to me now:
TotalHoras = SUMX(Horas;if(Horas[Tipo]="M";Horas[Duration]/60;Horas[Duration]))
Thanks
Try double quotes? "M"
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.