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,
I have such data:
I've created 2 report tables for this and last week data (only LastWeek and ThisWeek are measures):
Solved! Go to Solution.
Hi, @Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
Calendar(a calculated table):
Calendar = CALENDARAUTO()
There is no relationship between two tables. You may create calculated columns and a measure as below.
Calculated column:
YearWeekCal = YEAR('Calendar'[Date])*100+WEEKNUM('Calendar'[Date])
YearWeek = YEAR('Table'[Date])*100+WEEKNUM('Table'[Date])
WeekDesc =
var _yw = YEAR(TODAY())*100+WEEKNUM(TODAY())
var _lastyw =
CALCULATE(
MAX('Calendar'[YearWeekCal]),
FILTER(
ALL('Calendar'),
[YearWeekCal]<_yw
)
)
return
IF(
[YearWeek]=_yw,
"This Week",
IF(
[YearWeek]=_lastyw,
"Last Week"
)
)
Measure:
Result =
var lastfailrate= (LOOKUPVALUE('Table'[Failed%],'Table'[WeekDesc],"Last Week")*100)&"%"
var failrate = (LOOKUPVALUE('Table'[Failed%],'Table'[WeekDesc],"This Week")*100)&"%"
var lastuntestrate = (LOOKUPVALUE('Table'[Untested%],'Table'[WeekDesc],"Last Week")*100)&"%"
var untestrate = (LOOKUPVALUE('Table'[Untested%],'Table'[WeekDesc],"This Week")*100)&"%"
var lastfailgroups = LOOKUPVALUE('Table'[Failed Groups],'Table'[WeekDesc],"Last Week")
var failgroups = LOOKUPVALUE('Table'[Failed Groups],'Table'[WeekDesc],"This Week")
return
"Failure:"&lastfailrate&"->"&failrate&";"&
"Untested:"&lastuntestrate&"->"&untestrate&";"&
"Failed Groups:"&lastfailgroups&"->"&failgroups
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
Calendar(a calculated table):
Calendar = CALENDARAUTO()
There is no relationship between two tables. You may create calculated columns and a measure as below.
Calculated column:
YearWeekCal = YEAR('Calendar'[Date])*100+WEEKNUM('Calendar'[Date])
YearWeek = YEAR('Table'[Date])*100+WEEKNUM('Table'[Date])
WeekDesc =
var _yw = YEAR(TODAY())*100+WEEKNUM(TODAY())
var _lastyw =
CALCULATE(
MAX('Calendar'[YearWeekCal]),
FILTER(
ALL('Calendar'),
[YearWeekCal]<_yw
)
)
return
IF(
[YearWeek]=_yw,
"This Week",
IF(
[YearWeek]=_lastyw,
"Last Week"
)
)
Measure:
Result =
var lastfailrate= (LOOKUPVALUE('Table'[Failed%],'Table'[WeekDesc],"Last Week")*100)&"%"
var failrate = (LOOKUPVALUE('Table'[Failed%],'Table'[WeekDesc],"This Week")*100)&"%"
var lastuntestrate = (LOOKUPVALUE('Table'[Untested%],'Table'[WeekDesc],"Last Week")*100)&"%"
var untestrate = (LOOKUPVALUE('Table'[Untested%],'Table'[WeekDesc],"This Week")*100)&"%"
var lastfailgroups = LOOKUPVALUE('Table'[Failed Groups],'Table'[WeekDesc],"Last Week")
var failgroups = LOOKUPVALUE('Table'[Failed Groups],'Table'[WeekDesc],"This Week")
return
"Failure:"&lastfailrate&"->"&failrate&";"&
"Untested:"&lastuntestrate&"->"&untestrate&";"&
"Failed Groups:"&lastfailgroups&"->"&failgroups
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , Not very clear. If you need this week vs last week refer to my blog
It uses Date table and week rank
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
@Anonymous Yes, a little hard to follow but should be along the lines of something like:
Measure =
"Failure: " & CALCULATE([Failed %],<last week>) & "->" & CALCULATE([Failed %],<this week>) & "; Untested: "...
For a good example of doing something like this:
Otherwise, @ me in replies and I would need more details. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.
@Greg_Deckler , thank you for your answer.
Your measure is very likely what I need, but it is not possible to use [Failed%] and [Untested%] columns, because they are calculated columns but not measures. I noticed, that I could use only measures in your suggested formula.
@Anonymous To use columns in a measure formula, you need to wrap the column in an aggregation like MAX, MIN, SUM, AVERAGE, etc. I often use MAX or MIN if I am confident that there is only a single value for the column within the current context.
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 |
---|---|
112 | |
97 | |
84 | |
67 | |
60 |
User | Count |
---|---|
150 | |
120 | |
99 | |
87 | |
68 |