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
azakir
Resolver I
Resolver I

IF Condition To Display All Values From A Column

Hi Guys.

Need some help on an IF formula that I am trying to work out. Here's sample data:

 

azakir_0-1659654707998.png

 

What I am after is a measure which counts the number of Equipment code if OEM model is "793", else shows the equipment code.

I've worked out a basic formula which satisfy the first condition of count, but does not show all the equipment codes (possibly because of MAX):

 

azakir_3-1659654861987.png

 

 

Ideally, the formula should show something like below:

 

azakir_2-1659654790853.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Guys

My approach using a calculated table. However getting error for "variant data type". Any suggestions?

Table =
ADDCOLUMNS (
    SUMMARIZECOLUMNS (
        'Equipment OEM'[Equipment OEM],
        "Count of Equipment", COUNTROWS ( 'Equipment OEM' )
    ),
    "Measure",
        IF (
            [Count of Equipment] >= 2,
            [Count of Equipment],
            FORMAT ( 'Equipment OEM'[Equipment OEM], "#.##" )
        )
)



 Thanks

View solution in original post

5 REPLIES 5
Kaly
Resolver II
Resolver II

Hi @azakir ,

According to your description, you can get it by a calculated column instead of a measure, because before you put the measure in the visual, it only has three rows in the Equipment OEM column(320, 493, 950), then according to the context, the measure can only produce three rows.

There're two tables based on your formula, I create a sample.

Equipment OEM Model table:

Kaly_0-1660202406441.png

Equipment table:

Kaly_1-1660202441283.png

The two tables are related with the Equipment OEM column. Here's my solution, create a calculated column in the Equipment table:

Column =
IF (
    'Equipment'[Equipment OEM] = 793,
    CONVERT (
        COUNTROWS ( FILTER ( 'Equipment', 'Equipment'[Equipment OEM] = 793 ) ),
        STRING
    ),
    'Equipment'[Equipment Description]
)

Get the result:

Kaly_2-1660202752665.png

Best Regards,

Kaly

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @Kaly 

Thank you for your reply and detailed explanation. You are right, having a measure won't really help. And your solution did the trick for me. Thank you for that. 

Anonymous
Not applicable

Guys

My approach using a calculated table. However getting error for "variant data type". Any suggestions?

Table =
ADDCOLUMNS (
    SUMMARIZECOLUMNS (
        'Equipment OEM'[Equipment OEM],
        "Count of Equipment", COUNTROWS ( 'Equipment OEM' )
    ),
    "Measure",
        IF (
            [Count of Equipment] >= 2,
            [Count of Equipment],
            FORMAT ( 'Equipment OEM'[Equipment OEM], "#.##" )
        )
)



 Thanks

MahyarTF
Memorable Member
Memorable Member

Hi,

Not sure if it is the best solution :

- In Power Query, I create two duplicated tables from my specific Table (T1 and T2)

- In T1, I filter the 'Equipment OEM' = 732

- In T2, I filter the 'Equipment OEM' <> 732

- In T1, Group Rows based on the 'Equipment OEM'

MahyarTF_0-1659660484260.png

- In T1, changed the type 'Equipment' type to Text

- Append the T1 and T2 and Apply them to Power BI

- In Power BI, create the Table visual and bring the 'Equipment OEM' and 'Equipment' column

MahyarTF_2-1659660619999.png

Mahyartf

Hi @MahyarTF . thanks for the suggestion. The issue is I've got a few more OEM model numbers that needs to be counted apart from 793. So thought I'll just include them in a formula for easy filtering

 

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.