Solved

Some custom measures in PBI semantic models doesn't works


Userlevel 3
Badge +1

I’ve detect that some dax code doesn’t works in PBI.

Are there some guide abut this?

 

icon

Best answer by fwagner 13 February 2023, 21:23

View original

11 replies

Userlevel 6
Badge +5

Hi @rvgfox 

Can you please share a specific example of a DAX custom measure, which you are having issues with, and screenshots of the error in Power BI? 

Userlevel 3
Badge +1

Hi @Christian Hauggaard 

I’ve the measure:

[User culture]=USERCULTURE()

If you define it in TX when you publish the report to the service doesn’t works.

If you define it directly in PBI and publish the report to the service it works.

 

Userlevel 6
Badge +5

I manage to create the custom measure without any issues. I create a custom measure and then I select the PowerBI Premium endpoint in the left hand menu and for the script I simply enter USERCULTURE()

Then I deploy and execute the semantic model. And in PBI I create a report on top of my dataset, which displays the value en-US when I bring the measure into a table.

Are you using different settings to the ones described above?

Userlevel 3
Badge +1

Ok, It works in PBI desktop but if you publish the report to the service it doesn’t works.

 

Yo can test the direrent user cultures with /?language=es-ES at the end of the report url and you will see that the measure created from TX doesn’t works but directly from PBI it works.

Userlevel 6
Badge +5

For me it seems to be working as expected. I opened Power BI desktop, selected Get Data > Power BI Datasets.

Selected my PBI dataset published from TimeXtender. Added the measure to a table visualization.

Saved and published my report.

Opened the report in the PBI service. Added the user culture at the end of the URL as described by you. And now the measure says “es-ES” as expected. 

Am I doing something differently from you?

Userlevel 3
Badge +1

Try to use a report with storage mode mixed.

Userlevel 6
Badge +5

where do you set the storage mode? have you tried with other storage modes than mixed?

Userlevel 3
Badge +1

The idea it’s connect from PBI to the model generated by TX and convert it to a “local model” to add for example calculation groups.

In that type of storage the measure created from TX doesn’t works.

Userlevel 2
Badge +3

Hey @rvgfox 

that’s a very cool question!

I would suggest to create a “primary” or core tabular model in TimeXtender, then add a secondary model, with a live connection to the primary, and all the features, such as calculation groups and additional measures on top.

We described the procedure in TimeXtender Tuesdays Episode 26: Calculation Groups

 

 

For reference: these are the steps I took to test your scenario:

1. enable the Preview Feature DirectQuery for PBI data sets and AS: 

 

2. connect to the primary PBI dataset

​​​

​​​​3. change to a DirectQuery connection:

 

4. select all content of the primary model

 

5. make sure the secondary model is in DirectQuery mode

 

6. architecture/lineage of the end result looks like this

With that, I created a USERCULTURE() measure, both in the primary model (in TimeXtender), and also in the secondary model in Power BI Desktop.

The secondary model respects changing user cultures, while the culture is apparently not passed down to the core/primary model, as you can see here:

 

Now, I would also have expected that the culture is propagated downwards, but apparently it is not.

So therefore, I would advise to built your core measures, i.e. the numerical calculations, into the primary model, within TimeXtender, and display/formatting related stuff, that changes with culture into the secondary model, built with Power BI Desktop:

 

Side note: the behaviour you discovered is not a limitation in TimeXtender, but a limitation in Power BI / DirectQuery on Tabular Models. Since the feature is still in Preview Mode, maybe it will be fixed by Microsoft - would be cool if it were. Searching https://ideas.powerbi.com/ideas/, I couldn’t find anything related there, yet.

I hope that helps, please let us know if the suggested way works for your situation.

Userlevel 3
Badge +1

Yes @fwagner that it’s exactly the problem that I found, because I’m using the mixed storage mode to be able to use calculation groups, and the userculture() function must be include in that mode, otherwise, if you include it in TX it doesn’t works.

Another thing that I discovered it’s that if you use the property “format string expression” for a calculation item group, in that kind of model, it doesn’t works too.

 

Userlevel 6
Badge +5

@rvgfox did Frank’s response answer your question? If so, could you please help us by marking it as best answer? If you have any follow up questions, please let us know 

Reply