Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hi all,
I am currently stuck in my mind, hope you can help me out.
I have two tables in my datamodel. One fact table named 'Dossier', translated to English it is file. In the Dossier table I have a column 'Datum in werkvoorraad' and 'Datum uit werkvoorraad'. You can translate werkvoorraad to pipeline I think. It says something about when there was being worked on a file, a from to and until date.
I also have a seperate date table, which contains a full one year back. So in DAX terms:
Solved! Go to Solution.
try
Werkvoorraad 2 =
GENERATE( ALLNOBLANKROW(Kalender[Datum]),
CALCULATETABLE(
var meetdatum = SELECTEDVALUE( Kalender[Datum])
var temptabel =
filter(Dossier, Dossier[Datum in werkvoorraad] <= meetdatum &&
(Dossier[Datum uit werkvoorraad] > meetdatum || isblank(Dossier[Datum uit werkvoorraad])))
return selectcolumns(temptabel, "ID dossier", Dossier[id Dossier])
)
)
You can use GENERATE, .e.g
New Table = GENERATE( ALLNOBLANKROW('Date'[Date]),
var meetdatum = SELECTEDVALUE( 'Date'[Date])
var temptabel = filter(dossier, Dossier[Status - Datum aanvraag] <= meetdatum &&
((COALESCE(Dossier[Status - Datum finaal akkoord], Dossier[Status - Beëindigd op]) > meetdatum) ||
(isblank(COALESCE(Dossier[Status - Datum finaal akkoord], Dossier[Status - Beëindigd op]))) &&
(Dossier[D_RedenBeeindiging] <> 5 || isblank(Dossier[D_RedenBeeindiging])) &&
Dossier[Ind niet tellen (dubbel dossier)] = "Meetellen" ))
)
Hi John, thank you for your quick reply.
I have adjusted the DAX formula in the table but I am getting an error:
I think the error is in the code you originally posted, when I tried to use DAX formatter it gave an error.
Take your existing code and use that as the 2nd argument to GENERATE, replacing the definition of meetdatum with the version I posted.
Hi John,
First of all, thanks again 🙂
I have replaced the code with the existing code, but I am getting no result in the table:
Hmm, it all looks correct. Is it possible to share the PBIX if it doesn't contain confidential information?
Another thing you could try is replacing the SELECTEDVALUE for the meetdatum with an actual fixed date which you know works, as in your original post. That would at least prove that the code is working correctly.
I just tried, the weird thing is that all dates seem to be returned:
I would expect that only the filled in date would be in the list (15th of januari 2021).
Sadly I am not able to share the .pbix, there is confidential information in the file.
That behaviour is expected. Its returning all the dates because at the moment there is no connection between the date column and the calculation, its just using one flat date so it will return the same rows for every entry in the date column.
The only small thing I can see is that your date column is a datetime not just a date. I don't know if that will make any difference, but you could try changing it to be a date type. Other than that I think I'm out of ideas.
I changed both the date in the werkvoorraad 2 table and time table to just date, not date/time. It did not resolve the issue. My current DAX formula for the werkvoorraad table is now:
Werkvoorraad 2 =
GENERATE( ALLNOBLANKROW(Werkvoorraad[Datum]),
var meetdatum = SELECTEDVALUE( Werkvoorraad[Datum])
var temptabel = /*filter(Dossier, Dossier[Status - Datum aanvraag] <= meetdatum &&
((COALESCE(Dossier[Status - Datum finaal akkoord], Dossier[Status - Beëindigd op]) > meetdatum) ||
(isblank(COALESCE(Dossier[Status - Datum finaal akkoord], Dossier[Status - Beëindigd op])))) &&
(Dossier[D_RedenBeeindiging] <> 5 || isblank(Dossier[D_RedenBeeindiging])) &&
Dossier[Ind niet tellen (dubbel dossier)] = "Meetellen" )*/
filter(Dossier, Dossier[Status - Datum aanvraag] <= meetdatum &&
(COALESCE(Dossier[Status - Datum finaal akkoord], Dossier[Status - Beëindigd op]) > meetdatum ||
isblank(COALESCE(Dossier[Status - Datum finaal akkoord], Dossier[Status - Beëindigd op]))) &&
(Dossier[D_RedenBeeindiging] <> 5 || isblank(Dossier[D_RedenBeeindiging])) &&
Dossier[Ind niet tellen (dubbel dossier)] = "Meetellen" )
return SELECTCOLUMNS(temptabel, "ID dossier", Dossier[id Dossier])
)
Just as a test, try the below
Test Table = GENERATE(ALLNOBLANKROW(Werkvoorraad[Datum]),
ROW( "same date", SELECTEDVALUE(Werkvoorraad[Datum])
)
just to make sure that SELECTEDVALUE is working as I think it and is correctly picking up the row context. It should give you a 2 column table with the same date in each column.
Hi John,
This is the result:
Try
Test Table = GENERATE(ALLNOBLANKROW(Werkvoorraad[Datum]),
CALCULATETABLE( ROW( "same date", SELECTEDVALUE(Werkvoorraad[Datum]))
)
that will force context transition and we may need a CALCULATETABLE in the main table if this works
Hi John, thanks again!
It works in the test table now:
How do I integrate the calculatetable in the existing table? I tried but I don't know exactly what I am doing, and it also does not work. This is my currect query:
Werkvoorraad 2 =
GENERATE( ALLNOBLANKROW(Werkvoorraad[Datum]),
var meetdatum = SELECTEDVALUE( Werkvoorraad[Datum])
var temptabel =
calculatetable(filter(Dossier, Dossier[Datum in werkvoorraad] <= meetdatum &&
(Dossier[Datum uit werkvoorraad] > meetdatum || isblank(Dossier[Datum uit werkvoorraad]))))
return SELECTCOLUMNS(temptabel, "ID dossier test", Dossier[id Dossier])
)
@johnt75 I am not getting it to work. My current code:
Werkvoorraad 2 =
GENERATE( ALLNOBLANKROW(Kalender[Datum]),
var meetdatum = SELECTEDVALUE( Kalender[Datum])
var temptabel =
filter(Dossier, Dossier[Datum in werkvoorraad] <= meetdatum &&
(Dossier[Datum uit werkvoorraad] > meetdatum || isblank(Dossier[Datum uit werkvoorraad])))
/*return calculatetable(row("ID dossier", SELECTCOLUMNS(temptabel, "ID dossier test", Dossier[id Dossier])))*/
return calculatetable(selectcolumns(temptabel, "ID dossier", Dossier[id Dossier]))
)
try
Werkvoorraad 2 =
GENERATE( ALLNOBLANKROW(Kalender[Datum]),
CALCULATETABLE(
var meetdatum = SELECTEDVALUE( Kalender[Datum])
var temptabel =
filter(Dossier, Dossier[Datum in werkvoorraad] <= meetdatum &&
(Dossier[Datum uit werkvoorraad] > meetdatum || isblank(Dossier[Datum uit werkvoorraad])))
return selectcolumns(temptabel, "ID dossier", Dossier[id Dossier])
)
)
Wow, this worked! Thanks John!
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
User | Count |
---|---|
88 | |
85 | |
68 | |
68 | |
64 |
User | Count |
---|---|
209 | |
118 | |
116 | |
81 | |
74 |