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.
I have two tables with related information. The "Fact" table has transaction information with the following relevant fields:
Fact Table
Date
Model
Single/Double (Either tells us whether it's a single or double unit - the only two options)
Units
Sales
Dim Table
Model
Pricing Start Date
Pricing End Date
Pricing for Single Units (for date range)
Pricing for Double Units (for date range)
What I want to do:
I want to evaluate, for each row in the fact table, what the actual pricing "should" have been.
For example:
If - Model-Fact Table matches Model - Dim Table
&&
Date falls between pricing start date & end date
&&
Single/Double = Double
Then Return:
Value in Column "Double Pricing" that matches the model and date range.
I know conceptually what I'm trying to do but don't know whether to do this in PQ or dax, or how to set up the relationships so I can reference another table when creating a new column. I'm still learning, obviously, but thought I'd be able to figure this out 😞
Solved! Go to Solution.
a new column in fact
new colum =
var _unit = [Units]
return
maxx(filter(dim, Dim[Model] = Fact[Model] && Fact[Date] >= Dim[Pricing Start Date] && Fact[Date] <= Dim[Pricing End Date] ), if(_unit =1, [Pricing for Single Units],[Pricing for Double Units] ) )
Hi,
Write this column in the Fac table
Price = if(fact[Single/Double]="double",calculate(sum(Dim[Pricing for Double Units]),filter(Dim,dim[model]=earlier(fact[model])&&dim[pricing start date]<=earlier(fact[Date])&&dim[pricing end date]>=earlier(fact[Date]))),blank())
Hi,
Write this column in the Fac table
Price = if(fact[Single/Double]="double",calculate(sum(Dim[Pricing for Double Units]),filter(Dim,dim[model]=earlier(fact[model])&&dim[pricing start date]<=earlier(fact[Date])&&dim[pricing end date]>=earlier(fact[Date]))),blank())
a new column in fact
new colum =
var _unit = [Units]
return
maxx(filter(dim, Dim[Model] = Fact[Model] && Fact[Date] >= Dim[Pricing Start Date] && Fact[Date] <= Dim[Pricing End Date] ), if(_unit =1, [Pricing for Single Units],[Pricing for Double Units] ) )
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
106 | |
105 | |
79 | |
69 | |
62 |
User | Count |
---|---|
142 | |
105 | |
103 | |
84 | |
70 |