English 中文(简体)
DAX expression for Power BI measure
原标题:

I am trying to create a measure in POWER BI, its to calculate the total revenue for a time period but it has a lot of conditions to it. i.e.

Total Revenue with following conditions Shipping type = "Incoming"

Status = Invoiced,Shipped,Received

if site = 29104 exclude product = S-ExtFreight,S-ProductInDelivery,S-WeighOnly

if site = 33103 exclude product = S-ExtFreight,S-WeighOnly

if site = 23103 exclude product = S-ExtFreight,SAxleWeigh

I tried to use the below expression but its not throwing me any values when I plot it on a graph.

Measure 2 = CALCULATE( sum( Fact table [Amount]), Fact table [Site Code] = 29104 & Fact table [Item Number] in {"S-ExtFreight","S-ProductInDelivery","S-WeighOnly"}, Fact table [Site Code] = 33103 & Fact table [Item Number] in {"S-ExtFreight","S-WeighOnly"}, Fact table [Site Code] = 23103 & Fact table [Item Number] in {"S-ExtFreight","S-AxleWeigh"})

问题回答

You have to use NOT in to exclude products. Also you need to use && for AND condition.

Measure 2 = CALCULATE( sum( Fact table [Amount]),  Fact table [Site Code] = 29104 &&  Fact table [Item Number] NOT in {"S-ExtFreight","S-ProductInDelivery","S-WeighOnly"},  Fact table [Site Code] = 33103 &&  Fact table [Item Number] NOT in {"S-ExtFreight","S-WeighOnly"},  Fact table [Site Code] = 23103 &&  Fact table [Item Number] NOT in {"S-ExtFreight","S-AxleWeigh"})




相关问题
Monitoring a calculated data (A person s age) in SQL Server

I have a table, tblClient, which stored a client s date of birth in a field of type datetime, DOB. The goal here is that, when a client reaches 65 years old (need to be calculated thru DOB), I need ...

Is Custom Text supported in Computed columns?

Is there any way of adding custom text in an computed column? For example this formula works great ([Duration] + 12 ) Could i have a result, from a computed column, similar to this one? ([...

Foreign Key reference in mysql innodb

Simply put: I have a table with 2 columns: one is username and other is nickname. I have another table where I have 2 columns: one is username and other is countNicknames. I want countNicknames to ...

SQL Server WHERE Clause using Temporary Columns

I have the following query, which uses a CASE statement. Is there anyway to add into the where clause WHERE IsBusinessDayFinal = 0? without using a temporary table? thanks so much! SELECT ...

Wrong Result after Refresh pressed on DbNavigator Delphi

I have faced a very strange situation here. I am accessing database (MDB) through JET. I use DBGrid and DBNavigator to allow user access it. Dataset is created using TADOQuery component, with the ...

热门标签