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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Ramon_CN
Regular Visitor

Goup by and count occurences meassure

Hi everybody. I'm new on the board.

 I have this Table  (VendesAnnex),

Order NumLine NumPX
14181True
14182True
14183False
14191True
14192True
14201False
14202False
14211True
14212False
14221False
14222False
14223False
14224False

And need a meassure that returns True/False after grouping (Vendes Annex) by [Order Num] where True means at least 1 [Line num] = "True" and False means that none [Line Num] ="True":

Expected Resul would be:

 

Order NumPX
1418True
1419True
1420False
1421True
1422False

 

If it is in two steps/Meassures is not a problem. I' ve tried different ways and the ouput I get is a filtered table where all values are "True". 

 

Thanks Folks!

2 ACCEPTED SOLUTIONS
FreemanZ
Super User
Super User

hi @Ramon_CN ,

 

try to plot a table visual with Order Number and a measure like:

OrderPX = 
IF(
    TRUE in VALUES(data[PX]),
    TRUE, FALSE
)

 

it worked like:

FreemanZ_0-1702817928757.png

 

View solution in original post

@Ramon_CN 

Glad you had your problem resolved.

I made the DAX calculation assuming you had logical values as TRUE and FALSE but it is text, that's the reason you faced this issue. As pointed out by @FreemanZ , you can modify my measure as follows and it should work. 

Num pX = TRUE IN VALUES( TableName[PX] )




Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

8 REPLIES 8
Fowmy
Super User
Super User

@Ramon_CN 

Use this meaure:

Num pX = TRUE() IN VALUES( TableName[PX] )



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thanks Fowmy for your help.

Your code seems very elegant, And it may work but not to me. 

I tried it in a plane orders Visual table, and it colapsed.

Message Error on CONTAINSROW does not allow comparing values text type with True/False Type. 

Thanks anyway. 

@Ramon_CN 

Glad you had your problem resolved.

I made the DAX calculation assuming you had logical values as TRUE and FALSE but it is text, that's the reason you faced this issue. As pointed out by @FreemanZ , you can modify my measure as follows and it should work. 

Num pX = TRUE IN VALUES( TableName[PX] )




Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Fantastic Fowmy.

Your meassure works great now!

Thanks a lot for your concern. 

i think that is a typo, this shall work:

measure = TRUE in VALUES(data[PX])

Thanks for your help FreemanZ. 

FreemanZ
Super User
Super User

hi @Ramon_CN ,

 

try to plot a table visual with Order Number and a measure like:

OrderPX = 
IF(
    TRUE in VALUES(data[PX]),
    TRUE, FALSE
)

 

it worked like:

FreemanZ_0-1702817928757.png

 

Thanks a lot. Example file helped  much.

Code worked fine. 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.