简体   繁体   中英

PowerBI Condition

I would like to know if it's possible to do what I'm trying to do in Power BI. It must check conditions and based on it tell something about that comparision. Using excel is really easy to do that, just an If.

I'm planing to make a comparission tool.

预期结果

Power BI is not so powerful for doing this stuff, but it is still possible. You need to create two exactly same tables with your data. Then, for the Table1, sort by age and then add indexed column starting from 0. Similar, for Table2, sort by age and then add indexed column starting from 1.

After that, merge these two tables with left outer join, based on index columns. You are almost there: in newly created merged table, add column with the following formula:

if(Merge1[Age]> Merge1[Table2.Age],Merge1[Name],Merge1[Table2.Name]) & " is older than "&Merge1[Table2.Name]

You will get something like this: 在此处输入图片说明

Hope that this helps.

If you don't want to create two tables for your selection, you can use multi-select on a single slicer.

例子

The measure I use on the card is this:

Older = 
VAR Name1 = MIN(Table01[Name])
VAR Name2 = MAX(Table01[Name])
VAR Age1 = CALCULATE(SELECTEDVALUE(Table01[Age]), Table01[Name] = Name1)
VAR Age2 = CALCULATE(SELECTEDVALUE(Table01[Age]), Table01[Name] = Name2)
RETURN
IF(
    Age1 > Age2,
    Name1 & " is older than " & Name2,
    Name2 & " is older than " & Name1
)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM