Can I call a custom function in DAX? - powerbi

I have created a custom function networkdays in Power Query Editor.
and I would like to call it while writing DAX code in Report Section. But I do not see the networkdays function available to me.
Can someone please explain the workaround?
Thank You

You cannot call a PQ function from DAX. They are completely separate environments. BTW, DAX already has a NETWORKDAYS() function.

Related

Unable to execute measure stored in Analysis Services/Power BI

I'm trying to see if I can write tests in C# that will validate the measures in a model; to do I need to execute the measure and compare the result with an implementation in C# that should be the same.
I've set up a basic Power BI-report containing a couple of tables and measures. One of the measures is a simple count('fact_data'[Item]), and works as expected when I'm looking at it in the report.
When connecting to the model via ADOMD.NET I'm able to extract the measure expression programmatically, but when I try to run it via the AdomdDataAdapter all I get is
AdomdErrorResponseException: Query (1, 18) The syntax for '[Item]' is incorrect. (COUNT('fact_data'[Item])).
Other and more basic queries where I simply return table contents work without problem.
No matter what I try I cannot get this to execute; if I rename the column or table to something that doesn't exist, I get an error about this so it would seem that the query is executed, but that something is either wrong or missing in the syntax.
I still don't know how to do this via ExecuteScalar(), but wrapping the DAX in a ROW() seems to work for stored measures.

Want to bring over many columns from another table to a table that has a column of matching values

I have two (2) tables in Power Bi and I wish to bring over several columns from a table that has a column of matching values (there are many columns that I don't need). What is the best way to do so? I tried DAX query but it only allowed for one column to bring over using the LOOKUP function. I tried to merge the queries but didn't quite understand how to get it to work as the table expanded did not match up to the values. Some help please for performing this operation would be greatly appreciated. Thank you.
Don't do it with DAX, use Power Query to merge on the key column. This can all be achieved using the menu and options, no code required. This is the same as in Excel, so here's a walkthrough from Microsoft that goes through all the steps you might need.Once you start using Power Query you won't look back. Good Luck!

How to join two or more DAX tables in DAX studio

I am looking for a way to do a LEFT JOIN like in SQL but with DAX. I have two tables employee table and department table. I want to join two DMV tables(views) in DAX studio.
I have tried using the evaluate function
EVALUATE NATURALINNERJOIN($SYSTEM.DBSCHEMA_COLUMN,$SYSTEM.TMSCHEMA_COLUMNS)
but getting syntax error.
DMV Dax studio
The easiest way to join in dax is having the tables related. This article should help you manage joins.
https://www.sqlbi.com/articles/from-sql-to-dax-joining-tables/
Just came across the same problem and solved it; you may already have, but thought I pass it along.
You had it right just missed one expression, the EVALUATE function.
EVALUATE
NATURALINNERJOIN($SYSTEM.DBSCHEMA_COLUMN,$SYSTEM.TMSCHEMA_COLUMNS)
Until I added "evaluate" I could not get DAX Studio to work for me.

Creating a measure using DAX function Left on a table from Azure Analysis service

I am trying to get the first 4 digits from a string from a table in Power BI. The connection is a live connection / Direct which does not allow me to edit the query. Also, I am unable to create a new column. So I have to stick with creating a new Measure.
Now, I am using the following formula to get what I need.
LocationCd = mid(vw_DW_Contracts[ContractNumber],1,5)
but, this is not working a the vw_DW_Contracts table cannot be used in a measure. Is there a workaround to such problem?
I do not have access to the analysis service so cannot make any modifications in the source.
Please help.
Thanks
but, this is not working a the vw_DW_Contracts table cannot be used in a measure.
I'm not sure what you mean by this, but I'm guessing the message you see is telling you that measures expect an aggregation. The formula you posted would be great as a calculated column where it can be evaluated row by row. Measures are aggregations over multiple rows.
If you are trying to make a new field that is the location code that can be used in visuals on a categorical axis, this should be a column rather than a measure. You could write a measure to show a location cd using something like LASTNONBLANK (mid(vw_DW_Contracts[ContractNumber],1,5), 1) but I doubt that is what you want.

[Power BI desktop]-Can create a report this template?

I'm new power BI desktop. I want create a report like this template? I tried but I can't do that.enter image description here
Please help me.
There are a couple of different ways you can achieve this however this is how I would go about it.
The table itself can be created easily by inputting the table visual. Here the settings can be configured through the formatting tab.
The biggest issue you are having looks like it could be to do with the positive, negative numbers. There are actually a couple of really nice visuals that could help you with this: https://app.powerbi.com/visuals
The other alternative is to create your own visuals using R.