Forum Discussion
DAX IF measure - return fixed value
This should be a very simple requirement. But it seems impossible to implement in DAX.
Data model, User lookup table joined to many "Cards" linked to each user.
I have a measure setup to count rows in CardUser. That is working fine.
<measureA> = count rows in CardUser
I want to create a new measure,
<measureB> = IF(User.boolean = 1,<measureA>, 16)
If User.boolean = 1, I want to return a fixed value of 16. Effectively, bypassing measureA.
I can't simply put User.boolean = 1 in the IF condition, throws an error.
I can modify measureA itself to return 0 if User.boolean = 1
measureA> = CALCULATE ( COUNTROWS(CardUser), FILTER ( User.boolean != 1 ) )
Zubair_Muhammad, appreciate if you can take a look at this. :)
2 Replies
- v-danhe-msftMicrosoft Employee
Hi tinker ,
Could you please post some simple sample data and your desired result to have a test if possible?
You could see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Regards,
Daniel He
- Ashish_MathurSuper User
Hi,
Assuming the column Boolean is in the User Table (left hand side Table), drag the Boolean Table to your Table visual and write this measure
=IF(HASONEVALUE(User[Boolean]),IF(MAX(User[Boolean])=1,COUNTROWS(CardUser),16),BLANK())
Hope this helps.