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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Can anyone help me turn this logic into a measure?

So basically the measure will return different values based on whatever is currently selected at the slicer and it will only be counted if it meets the Identifier condition, anything else that does not meet it will be ignored and not counted.

 

 

 

Count = 
VAR CurrentStatus = SELECTEDVALUE('Show Options'[Option])
VAR Identifier = Table1[Checker]

if CurrentStatus = "Difference" && Identifier == 0 then count only the rows that meet the Identifier condition

else if CurrrentStatus = "Common" && Identifier == 1 then count only the rows that meet the Identifier condition

else if CurrentStatus - "All" then count all the rows

RETURN Whatever has been counted

 

 

 

4 REPLIES 4
v-yetao1-msft
Community Support
Community Support

Hi @Anonymous 

I don't quite understand your description .

If select Difference, comparing these two tables, there are only three differences between them, that is, the three rows where the Customer Code is empty, so the count of the two tables should be 3.

Conversely, if you choose Common, then the counts of the two tables should both be 9, because they have 9 the same, so what is your calculation logic ?

 

Best Regard

Community Support Team _ Ailsa Tao

Anonymous
Not applicable

@v-yetao1-msft 

I would be basing the Customer Code count on the Venue Code, so there are two venues which is Laguna and Bahamas. Laguna has 9 customer code count in table1 while it only has 6 customer code count in table2 (3 rows that are not matching), that is why if I select "Difference" only the customer code count of each Laguna from their respective tables will be counted since the Laguna from the two tables have differences, that is why the card visual for table1 should show 9 while the card visual for table2 should show 6. Meanwhile Bahamas in table1 has 3 customer code count and likewise the same in table2 (all 3 rows are matching), that is why it is the only thing that will be chosen when selecting "Common"

amitchandak
Super User
Super User

@Anonymous , Not very Clear

 

a new measure

 

Count =
VAR CurrentStatus = SELECTEDVALUE('Show Options'[Option])
VAR Identifier = Table1[Checker]
return
Switch( true() ,

"difference" , countrows(filter(Table1, Identifier =0)) ,
"Common" , countrows(filter(Table1, Identifier =1)) ,
"All", countrows(Table1)
)

 

Anonymous
Not applicable

@amitchandak 

I'm very sorry, I realised the question wasn't clear enough. Let me just revise it completely. I have two tables which I want to compare.

 

Table1

Venue CodeVenue NameCustomer Code
LagunaSuria101Suria
LagunaSuria102Suria
LagunaSuria103Suria
LagunaSuria104Suria
LagunaSuriaGENSURIA
LagunaSuriaGENSURIA
LagunaSuria105Suria
LagunaSuria106Suria
LagunaSuria107Suria
BahamasSunwayBah123
BahamasSunwayBah124
BahamasSunwayBah125

 

Table2

Venue CodeVenue NameCustomer Code
LagunaSuria101Suria
LagunaSuria102Suria
LagunaSuria103Suria
LagunaSuria104Suria
LagunaSuriaGENSURIA
LagunaSuriaGENSURIA
LagunaSuria 
LagunaSuria 
LagunaSuria 
BahamasSunwayBah123
BahamasSunwayBah124
BahamasSunwayBah125

 

So now I will have two card visuals which will display the count of customer code for each of the tables. If the slicer is selected at "All" then the card visual for table 1 will show 12 while the card visual for table 2 will show 9. If "Difference" is selected at the slicer then the card visual for table 1 should show 9 while card visual for table 2 will show 6. If "Common" is selected at the slicer then the card visual for table 1 should show only 3 while the card visual for table 2 will only show 3 as well (because Bahamas is the only common one).

 

How can I achieve that using a measure that will be directly put at the card visual?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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