Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
marsclone
Helper IV
Helper IV

From PowerBi to PowerPivot

I have a formula in PowerBi that I would like to use in PowerPivot.

Only in PowerPivot, selectedvalue is not available and I think I should use if(hasonevalue)?
However, I get the message:

In the Switch function, comparing values of type True/False with values of type Number is not supported. Consider using the Value or Format function to convert one of the values.

How should I modify the formula?

Thanks!

PowerBi formula:

Total IST c =

if(AND([IfFiltered]=true(),[CheckHoofd?]=1),

BLANK(),

SWITCH(TRUE(),

SELECTEDVALUE(Hoofd[Subtotal?])=0,[Total IST a],

SELECTEDVALUE(Hoofd[Subtotal?])=1,[Total IST b]))

PowerPivot formula:

Total IST c:=if(AND([IfFiltered]=true();[CheckHoofd?]=1);
BLANK();
SWITCH(TRUE();
IF(HASONEVALUE(Hoofd[Subtotal?]);0;[Total IST a]);
IF(HASONEVALUE(Hoofd[Subtotal?]);1;[Total IST b])
))

1 ACCEPTED SOLUTION

See the DAX documentation here - SELECTEDVALUE function - DAX | Microsoft Docs

Your 2nd parameter needs to be the field wrapped in VALUES()

edhans_0-1621993909603.png

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

4 REPLIES 4
v-yingjl
Community Support
Community Support

Hi @marsclone ,

Besides the equivalent expression, if you don't need to return an alternateResult,you can often just use MAX instead of SELECTEDVALUE when there is more than one value to choose from.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Microsoft Employee
Microsoft Employee

What data types are your [IfFiltered] and [CheckHoofd?] measures?  In any case, can you compare them to 0 or 1 instead of FALSE() or TRUE()?  Or you can wrap your measure in INT( ) to return 1 or 0 from a T/F measure.

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


@mahoneypat 

 

Hi Pat,

 

these are the measures i use, the IfFiltered is looking at text, the other ones to numbers. Number 5 goes wrong.

Thank you in advance!

 

1. CheckHoofd?:=Max(Hoofd[Subtotal?])

 

2. IfFiltered:=ISFILTERED(Grootboek[Ertragslage])

 

3. Total IST a:=sum('Grootboek 2'[Bedrag in EV])

 

4. Total IST b:=if(COUNTROWS(Hoofd)=1;
CALCULATE([Total IST a];
all(Hoofd);
Hoofd[Hoofd ID]<=VALUES(Hoofd[Hoofd ID])
)
)

 

5. Total IST c:=if(AND([IfFiltered]=true();[CheckHoofd?]=1);
BLANK();
SWITCH(TRUE();
IF(HASONEVALUE(Hoofd[Subtotal?]);0;[Total IST a]);
IF(HASONEVALUE(Hoofd[Subtotal?]);1;[Total IST b])
))

See the DAX documentation here - SELECTEDVALUE function - DAX | Microsoft Docs

Your 2nd parameter needs to be the field wrapped in VALUES()

edhans_0-1621993909603.png

 

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors