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.
Hello,
I'm new to this forum and Power BI, so please go easy on me 😁
I've been going nuts all afternoon, because a simple calculated column(as below) works in imported mode but not in direct query? Can somebody explain why this isn't working and how I may be able to fix it?
Hi, @CAB80
There are some limitation for calculated columns in DirectQuery mode. Calculated columns are limited to being intra-row, as in, they can only refer to values of other columns of the same table, without the use of any aggregate functions. For further information, please refer the official document .
As a workaround, you may try to create a measure. I created data to reproduce your scenario.
Testalq:
Calendar:
Calendar = CALENDARAUTO()
There is a one-to-one relationship between two tables.
You may create a measure as below.
Result =
var _season =
IF(
HASONEVALUE(Testalq[Season]),
VALUES(Testalq[Season])
)
return
CALCULATE(
MIN('Calendar'[Date]),
FILTER(
ALL(Testalq),
Testalq[Season] = _season
)
)
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.
Thanks so much for your repl and for putting effort in to help me find a solution. Unfortunately it has not solved my problem as yet though. The output from your solution does appear to be what I want, but it didn't work for me.
Firstly, my tables are connected ([Pack Date] - > [Date]) with a one to many relationship where the Calendar table is the one. Not sure if this impacts your solution.
Secondly, I would like the column/measure to be in the Calendar table. This is so I can't use this as a quick and simple reference for many other measures. It just makes sense to me. I tried your solution in both and it didn't work. Below is a pic of what happened when I put the measure in the other table(not the calendar table). When I put it in the Calendar table the output was only the first date across all seasons. So it didn't work either way.
Put simply, what I really want here is for every record in my Calendar table, to show me the corresponding season start date/end date(separately) for that season(basically fiscal year). This is why the calc column worked so well.
I'm really frustrated here because I felt I was really making progress with Power BI and now that I've switched to direct query, everything I learnt and applied is down the drain 😟
Anyway, any help you can offer is much appreciated.
Calculated column does not work in Direct Query mode. You have work in terms of measure
Try like
CalSeasonStartDate =
CALCULATE(Min('Calendar'[Date]),
filter(all(bi_Grader_BatchV), not(isblank(bi_Grader_BatchV[TotalBinWeight])) && bi_Grader_BatchV[Season] = max('Calendar'[Season])))
Refer how i done it with measure : https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-1-Time-Intell...
You need create measure and take care of context
Thanks for the prompt reply, but this did not work. It only gives me the start date across all seasons, not for reach season.See below. So its grabbing the Min date, but not for each of the seasons. For simplicity I only have two tables here, my calendar table and the bi_Grader_BatchV table which are lnked via date and packdate respectively. My code worked perfectly as a column in the imported file. The reason I wanted a column was so that I could easily reference any record to the start/end date of each season.
Any other help would be much appreciated.
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 |
---|---|
109 | |
98 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
100 | |
86 | |
64 |