Youness Drissi Slimani
Youness Drissi Slimani

Reputation: 149

Power BI create column with condition

My direct Query structure img

enter image description here

I want to create a column in FB_DATA_AD_ONLY to get the VALUE of FB_ACTION_AD where the ACTION_TYPE="something" in power BI. I should keep the function " direct query". Do you think I can do this in Power BI ?

Upvotes: 2

Views: 1612

Answers (1)

Joe G
Joe G

Reputation: 1776

First, I would suggest looking at these site to understand the limitations of Direct Query (I know that I don't know all of the limitations).

Second, in the first one, it talks about a setting you can turn on to bypass some of the limitations Power BI imposes on Direct Query. To turn that option on, go to File -> Options and settings -> Options, then go to Direct Query and check the box next to Allow unrestricted measures in DirectQuery mode (Power BI will need to be restarted after checking that option).

Direct query setting

With that option checked, you can create some new measures in the data. I have some basic sample data (created using this SQL script).

Schema

Click on the ellipses ("...") next the your FB_DATA_AD_ONLY table (I'll be using my Buildings table) and select New measure. Enter the following formula

NewMeasure = CALCULATE(
    SUM(FB_ACTION_AD[VALUE]),
    FILTER(
        FB_ACTION_AD,
        FB_ACTION_AD[ACTION_TYPE] = "something"
    )
)

I used this formula.

EmpSum = CALCULATE(
    SUM(Employees[idemp]),
    FILTER(
        Employees,
        Employees[FirstName] = "Alex"
    )
)

I threw together a quick table and matrix to illustrate that the measure is returning the expected value (Alex is only assigned to one building and their ID is 2, so that building would have a EmpSum value of 2).

Results

Upvotes: 1

Related Questions