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
twister8889
Helper V
Helper V

If statement for columns in two tables without relationship

Hi guys,

 

I have two tables that don't contain one relationship, but I need to create an if to validate Qty Month. For example: If Qty Month > Start Range and < End Range then New, If Qty Month < End Range then Middle else Old

 

 

if without relationship.png

7 REPLIES 7
FrankAT
Community Champion
Community Champion

Hi @twister8889 

what about the following solution?

 

25-08-_2020_16-46-57.png

 

Result = 
SWITCH(TRUE(),
    'Table'[Qty Mont] >= 0  && 'Table'[Qty Mont] < 3, "New",
    'Table'[Qty Mont] >= 3  && 'Table'[Qty Mont] < 6, "Middle",
    "Old"
)

Regards FrankAT

@FrankAT  Thank you for your answer....

However, the range Start, End (0,3,6,..)  is dynamical, I can't put the values manually, I need to validate with columns from table2

Hi @twister8889
How does the dynamic change of the start and end values take place?
Regards FrankAT

The table with range is loaded by Excel for each client, so I have a range different. Sometimes for one client, the N is 4, another can be 7.... So this data is dynamic by the client and I can't put this data manually. I think the best way, is compare where the month qty is on the range table

Hi @twister8889 

I think you can do it like this:

 

26-08-_2020_13-40-28.png

Result = 
CALCULATE (
    VALUES ( 'Range Table'[Status] ),
    FILTER (
        'Range Table',
        'Range Table'[Start Range] <= 'Table'[Qty Mont]
            && (
                'Range Table'[End Range] > 'Table'[Qty Mont]
                    || 'Range Table'[End Range] = BLANK ()
            )
    )
)

Regards FrankAT
(Proud to be a Datanaut)

amitchandak
Super User
Super User

@twister8889 , create a new table in table 1

new column = maxx(filter(table2, table1[Qty Month] >= table2[Start Range] && table1[Qty Month] <= coalesce(table2[End Range],9999999)),table2[status])

Hi @amitchandak 

First of all, thank you for your answer

 

1-) I tried to do, but I have an error when I inserted the coalesce 

(cannot find name coalesce)

But without it, fine works.

 

2-) After my tests, I saw that I need one more validation, table2, table1[Qty Month] >= table2[Start Range] && table1[Qty Month] <= coalesce(table2[End Range],9999999) && table1[Status] = 1
It's possible increase the formula with this validation?

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.