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'm trying to create a new measure with multiple if statements however I'm getting an error. Any advice?
If ListingStatus = "Inactive" then calculate a particular expression using Calculate(sumx( with filters.
If ListingStatus = "Active" then calculate the same express with slightly different sumx filters.
Here is the measure:
*************************************************
Avg Asking Rate (Weighted) :=
IF (
Listing[ListingStatus] = "Inactive",
DIVIDE (
CALCULATE (
SUMX ( 'Listing', Listing[NetAskRate] * Listing[ListingAvailableSF] ),
Listing[NetAskRate] > 0,
DATESINPERIOD (
ListingRemovalDate[ListingRemovalDate_DateOnly],
TODAY (),
-12,
MONTH
)
),
CALCULATE (
SUM ( [ListingAvailableSF] ),
Listing[NetAskRate] > 0,
DATESINPERIOD (
ListingRemovalDate[ListingRemovalDate_DateOnly],
TODAY (),
-12,
MONTH
)
)
),
IF (
Listing[ListingStatus] = "Active",
DIVIDE (
CALCULATE (
SUMX ( 'Listing', Listing[NetAskRate] * Listing[ListingAvailableSF] ),
Listing[NetAskRate] > 0
),
CALCULATE ( SUM ( [ListingAvailableSF] ), Listing[NetAskRate] > 0 )
)
)
)
**************************************************
Here is the Error Warning:
Warning 1 Measure 'Listing'[Avg Asking Rate (Weighted)] : The value for column 'ListingStatus' in table 'Listing' cannot be determined in the current context. Check that all columns referenced in the calculation expression exist, and that there are no circular dependencies. This can also occur when the formula for a measure refers directly to a column without performing any aggregation--such as sum, average, or count--on that column. The column does not have a single value; it has many values, one for each row of the table, and no row has been specified. P:\MarketingTabularModel\MarketingTabularModel\Model.bim 0 0 MarketingTabularModel
Solved! Go to Solution.
Hi @bizintelguy604 ,
the first argument in your If-statement is not valid:
Avg Asking Rate (Weighted) :=
IF (
Listing[ListingStatus] = "Inactive",
this is referencing a whole column, but you need a single value (scalar) instead.
This could be achieved by an aggregtion function, like MIN or MAX:
Avg Asking Rate (Weighted) :=
IF (
MAX ( Listing[ListingStatus] ) = "Inactive",
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
@bizintelguy604 , Try like
Avg Asking Rate (Weighted) :=
IF (
max(Listing[ListingStatus]) = "Inactive",
DIVIDE (
CALCULATE (
SUMX ( 'Listing', Listing[NetAskRate] * Listing[ListingAvailableSF] ),
Listing[NetAskRate] > 0,
DATESINPERIOD (
ListingRemovalDate[ListingRemovalDate_DateOnly],
TODAY (),
-12,
MONTH
)
),
CALCULATE (
SUM ( [ListingAvailableSF] ),
Listing[NetAskRate] > 0,
DATESINPERIOD (
ListingRemovalDate[ListingRemovalDate_DateOnly],
TODAY (),
-12,
MONTH
)
)
),
IF (
max(Listing[ListingStatus]) = "Active",
DIVIDE (
CALCULATE (
SUMX ( 'Listing', Listing[NetAskRate] * Listing[ListingAvailableSF] ),
Listing[NetAskRate] > 0
),
CALCULATE ( SUM ( [ListingAvailableSF] ), Listing[NetAskRate] > 0 )
)
)
)
Hi @amitchandak ,
wondering if you spotted other flaws in the measure or did you just write out the full measure code with the changes I suggested?
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
@ImkeF , My bad miss. Thanks for pointing.
Hi @bizintelguy604 ,
the first argument in your If-statement is not valid:
Avg Asking Rate (Weighted) :=
IF (
Listing[ListingStatus] = "Inactive",
this is referencing a whole column, but you need a single value (scalar) instead.
This could be achieved by an aggregtion function, like MIN or MAX:
Avg Asking Rate (Weighted) :=
IF (
MAX ( Listing[ListingStatus] ) = "Inactive",
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
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 |
---|---|
104 | |
96 | |
80 | |
67 | |
62 |
User | Count |
---|---|
137 | |
106 | |
104 | |
81 | |
63 |