Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
paolo_cordini
Partner - Creator
Partner - Creator

Apparent set analysis inconsistency

Hello

In my Datamodel there is a calendar, linked to the fact table, as usual…:

paolo_cordini_0-1716280209865.png

 

Now, the measure in the table below has a set analysis which selects the dates above April 20th

paolo_cordini_1-1716280209869.png

 

The field “DataMovSettimana” contains the week, it is calculated in the script as Week(DataMov).

As you can see, the current selection is DataMovSettimana=18.

Then, as expected, the result is the intersection of the set analysis and the current selections, thus showing only dates pertaining to week 18.

So, the result of the table below is the expected one.

 

 

 

 

Then, I remove the dimension “DataMovSettimana” from the table, without modifying anything in the selections, and the result is shown below:

paolo_cordini_2-1716280209871.png

 

As you can see, the measure total value is different as it apparently disregards the selection of the week. Moreover, the espression “week(DataMov)” is not calculated for the dates excluded in the set analysis.

 

Then, I remove one of the selections (not the week). Now the result is correct….

paolo_cordini_3-1716280209873.png

 

 

 

Moreover, how this can be explained?

paolo_cordini_4-1716280209876.png

 

 

In order to debug it, I made a copy of the date fields, both in the fact table and in the calendar table

paolo_cordini_5-1716280209876.png

 

 

paolo_cordini_6-1716280209877.png

 

This is the result. Does it make sense? Anyway, it is a workaround for me in order to get correct results.

paolo_cordini_7-1716280209879.png

I guess there is some datamodel issue but I am running out of ideas to throubleshoot it.

Any suggestion?

 

Labels (1)
20 Replies
paolo_cordini
Partner - Creator
Partner - Creator
Author

Unfortunately, this is not the case...

paolo_cordini_0-1716301558670.png

 

and no duplicates in the numeric dates....

paolo_cordini_1-1716301611003.png

guess the issue is something more tricky

Firefly_cam
Partner - Contributor III
Partner - Contributor III

Paolo... these 2 are Dimension and measure
Please Do 2 Dimessions: DataMov and Num(DataMov)
Or in your implementation do Count(Distinct Num(DataMov)) instead of Num(DataMov).
I'm pretty sure I get what's happening there

Regards, Roman
marcus_sommer

Were there really all relevant fields included in the table-box? Just the dates are not enough else all DataMov versions and all fields from the object dimensions + measures as well as all selected fields. Often helpful is also to include an unique key and if none exists to create one with recno() and/or rowno() - just to ensure to see all data and to have a view on all possible duplicates.

Beside this make sure that there are no synthetic keys or circular loops within the data-model.

paolo_cordini
Partner - Creator
Partner - Creator
Author

Yes, you are right, but nevertheless, there should be something else

paolo_cordini_0-1716303324366.png

 

Firefly_cam
Partner - Contributor III
Partner - Contributor III

I think they've done a crazy thing and combined the As-of table with an actual Calendar using dual values In their DateKey. Which explains everything including the case when Only(Week(Date)) is not working
Screenshot 2024-05-21 at 20.26.44.png

Regards, Roman
paolo_cordini
Partner - Creator
Partner - Creator
Author

It is not this case.
I am not the author of the script but it is quite straightforward. It's a simple usual calendar, no As-of table...

paolo_cordini_0-1716303995169.png

 

Firefly_cam
Partner - Contributor III
Partner - Contributor III

That's the only way I can explain this and it makes sense. Also it explains why you need two identical dates in TabCalendario.

This case appears to be almost untraceable, tried on my end and only this formula worked:
Date(Num(Date))=Date#(Text(Date))
Screenshot 2024-05-21 at 20.46.17.png

 

Regards, Roman
marcus_sommer

I think the calendar is not the problem else the DataMov from the facts - and an extra parallele num() + isnum() and similar might be useful there. Further if there are several fact-tables with DataMov as key repeat the doubling of them as separate fields and apply them too in the above suggested table-box. It's very like that your issue comes from not proper associations.

paolo_cordini
Partner - Creator
Partner - Creator
Author

I simplified a lot the datamodel for debugging purpose.I kept only the fields involved in the example.

paolo_cordini_0-1716464048913.png

From here, if I use a LEFT KEEP when loading the "m-prosta" table then the issue is solved (the "ProdNome" field is included in the selections. But I have no explanation for this behavior. 

 

marcus_sommer

I think it means that the associations between the data were not suitable for your view and the selection within a sub-dimension restricted the other selections and/or the reverse was happens and there were a n:m relationship which wasn't covered by the object granularity/expressions.

Without diving deeper it's hard to say what's the issue but the above mentioned table-box with all related fields and depending on the data a recno() + rowno() from each single table should have provide hints in regard to gaps and/or a poor data-quality and/or any duplicates.

Many of such association-trouble could be avoided by developing the data-model from the beginning as a star-scheme which means a single fact-table with n surrounding dimension-tables.