Forum Discussion
InsightSeeker
Helper III
2 years agoNeed help with measure
I have got tables through between which I need to create a measure to get the desired results.
Conditional Logic:
- The IF statement checks if:
- Table 1 Customer equals Table 2 Customer
- Table 1 Tool equals "Yes"
- Type equals "Online"
- If all conditions are met, it returns table 1 Type
- If any condition is not met, it returns BLANK().
Table 1
| Customer | Tool | Type |
| 000000100 | Yes | Oracle |
| 000100160 | No | Not Applicable |
| 000100160 | Yes | SAP |
| 000100161 | No | Not Applicable |
| NYC2023 | Yes | Oracle |
| 000100400 | No | Not Applicable |
| 000101800 | Yes | Oracle |
| 000103900 | Yes | SAP |
| 000103901 | Yes | SAP |
| 000103902 | No | Not Applicable |
| 000103902 | No | Not Applicable |
| 000104500 | No | Not Applicable |
| 000104500 | No | Not Applicable |
| 000106400 | Yes | SAP |
| 000106500 | Yes | Oracle |
(Table 2) Result to be added in this table.
| Customer | Inv No | Status | Result |
| 000000100 | 12322311 | Online | Oracle |
| 000000100 | 12325209 | Offline | |
| 000100160 | 12328107 | Offline | |
| 000100160 | 12331005 | Offline | |
| 000100161 | 12333903 | Offline | |
| 000100161 | 12336801 | Offline | |
| NYC2023 | 12333903 | Online | Oracle |
| NYC2023 | 12336801 | Offline | |
| 000100400 | 12339699 | Offline | |
| 000101800 | 12342597 | Offline | |
| 000101800 | 12345495 | Online | Oracle |
| 000103900 | 12342597 | Online | SAP |
| 000103900 | 12345495 | Online | SAP |
| 000103901 | 12348393 | Offline | |
| 000103902 | 12351291 | Offline | |
| 000103902 | 12354189 | Offline | |
| 000104500 | 12357087 | Offline | |
| 000104500 | 12359985 | Offline | |
| 000106400 | 12362883 | Online | SAP |
| 000106500 | 12365781 | Offline |
I have tried with the below meaure but it is not returning the desired results.
Type =
VAR _Table1 = SELECTEDVALUE('Table 1'[Customer])
VAR _Table2 = SELECTEDVALUE('Table 2'[Customer])
VAR _tool = SELECTEDVALUE('Table 1'[Tool])
VAR _type = SELECTEDVALUE('Table 1'[Type])
VAR _status = SELECTEDVALUE('Table 2'[Status])
RETURN
IF(
_table1 = _table2 &&
_tool = "Yes" &&
_status = "Online",
_type,
BLANK()
)
Hi,
Please check the below picture and the attached pbix file.
Thank you.
Expected result measure = VAR _customerselect = SELECTEDVALUE('Table 2'[Customer]) VAR _statusselect = SELECTEDVALUE('Table 2'[Status]) VAR _type = SUMMARIZE ( FILTER ( 'Table 1', 'Table 1'[Customer] = _customerselect && 'Table 1'[Tool] = "Yes" ), 'Table 1'[Type] ) VAR _condition = _statusselect = "Online" RETURN IF ( _condition, _type )
3 Replies
- Jihwan_Kim
Super User
Hi,
I am not sure if I uderstood your question correctly, but if you want to create calculated column, please try something like below.
Please check the below picture and the attached pbix file.
Expected result calculated column = VAR _type = SUMMARIZE ( FILTER ( 'Table 1', 'Table 1'[Customer] = 'Table 2'[Customer] && 'Table 1'[Tool] = "Yes" ), 'Table 1'[Type] ) VAR _condition = 'Table 2'[Status] = "Online" RETURN IF ( _condition, _type )- InsightSeeker
Helper III
Hi Jihwan_Kim - The result you obtained is what I need. Instead of a calculated column, can I achieve this through a measure?
- Jihwan_Kim
Super User
Hi,
Please check the below picture and the attached pbix file.
Thank you.
Expected result measure = VAR _customerselect = SELECTEDVALUE('Table 2'[Customer]) VAR _statusselect = SELECTEDVALUE('Table 2'[Status]) VAR _type = SUMMARIZE ( FILTER ( 'Table 1', 'Table 1'[Customer] = _customerselect && 'Table 1'[Tool] = "Yes" ), 'Table 1'[Type] ) VAR _condition = _statusselect = "Online" RETURN IF ( _condition, _type )