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.
Hi All,
I'm looking to create a measure for availability for the same day last week. I've created the following formula which mostly works
Shop | Product | Avail |
A | A | 24% |
B | 50% | |
C | 76% | |
Total | 24% | |
B | A | 12% |
B | 20% | |
C | 28% | |
Total | 12% |
When I would expect something like this:
Shop | Product | Avail |
A | A | 24% |
B | 50% | |
C | 76% | |
Total | 50% | |
B | A | 12% |
B | 20% | |
C | 28% | |
Total | 20% |
Any help appreciated,
Thanks
Solved! Go to Solution.
Hi, @darylmc ,
you could write your measure like this:
LW Avail =
VAR _product =
CALCULATE ( SELECTEDVALUE ( History[Product] ) )
VAR _date =
CALCULATE ( MAX ( History[Date] ) )
VAR _store =
CALCULATE ( SELECTEDVALUE ( History[Store] ) )
RETURN
IF (
HASONEVALUE ( History[Product] ),
CALCULATE (
DIVIDE ( SUM ( History[avail_sum] ), SUM ( History[avail_count] ), "" ),
FILTER (
ALL ( History ),
History[Date] = _date - 7
&& History[Store] = _store
&& History[Product] = _product
)
),
CALCULATE (
DIVIDE ( SUM ( History[avail_sum] ), SUM ( History[avail_count] ), "" ),
FILTER ( ALL ( History ), History[Date] = _date - 7 && History[Store] = _store )
)
)
Cheers,
Sturla
Hi, @darylmc ,
you could write your measure like this:
LW Avail =
VAR _product =
CALCULATE ( SELECTEDVALUE ( History[Product] ) )
VAR _date =
CALCULATE ( MAX ( History[Date] ) )
VAR _store =
CALCULATE ( SELECTEDVALUE ( History[Store] ) )
RETURN
IF (
HASONEVALUE ( History[Product] ),
CALCULATE (
DIVIDE ( SUM ( History[avail_sum] ), SUM ( History[avail_count] ), "" ),
FILTER (
ALL ( History ),
History[Date] = _date - 7
&& History[Store] = _store
&& History[Product] = _product
)
),
CALCULATE (
DIVIDE ( SUM ( History[avail_sum] ), SUM ( History[avail_count] ), "" ),
FILTER ( ALL ( History ), History[Date] = _date - 7 && History[Store] = _store )
)
)
Cheers,
Sturla
Works like a charm!
Thanks
Try to create a new measure like
averagex(summarize(table,table[shop],table[Product],"_avg",[LW Avail]),_avg)
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
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 | |
95 | |
80 | |
67 | |
62 |
User | Count |
---|---|
138 | |
107 | |
104 | |
82 | |
63 |