Countif alternatives on Power BI ("ALL" Functions -> Memory allocation) - powerbi

I did what i wanted with excel by using Countif
I have Channel_Session_ID column, i want to count it without any filter and get only when count=1.
The problem is when i do it with ALL-ALLEXCEPT functions, i get memory allocation so i guess those functions are off the table. I wanted to try REMOVEFILTERS function but Power BI said its not a function(its' version is september 2021, don't have any idea about that error). The report column set has columns that are coming from different tables. Any ideas what should i do?

Related

How does one count the number of columns in a table in Power BI using Dax

In Power BI desktop this is my 'Table1':
How do I count the columns (not rows) using DAX? Ideally this would be a measure called ColCount.
The end results should be ColCount=4. I have tried invoked functions, but new tables are unwanted.
DAX doesn't really have a method for that.
PQ/M has this method:
let
Source = Table.ColumnCount
in
Source

If you just need SUM, then no need to create measure in DAX?

Is there any reason for using DAX measure such as SUM(Column1) instead of dropping the Column to table visual and then configuring the aggregation method in the table visual? Column1 contains numeric values only. I can see in Performance Analyzer that calculations take the same amount of time. Is there any scenario when DAX measure would be superior than using a numeric column directly? I have tested it on a larger model, using slicers and filters, and I consistently got the same duration for both methods.
When I copy DAX query code to DAX Studio I can see the drop Column method is expanded to CALCULATE(SUM. So it seems that if you just need SUM, then no need to create measure in DAX.
The difference here is explicit vs implicit measures. Explicit measures are the ones you define. Implicit measures are the ones automatically defined by Power BI.
In terms of performance, there is no difference. The engine is doing the same thing in both cases.
However, it's generally considered best practice not to use any implicit measures for a variety of reasons such as:
Explicit measures are reusable (useful as building blocks for more complex measures) and can be organized into display folders.
Implicit measures won't show up in external programs like Analyze in Excel.
See these articles for further information:
Explicit Vs Implicit DAX Measures in Power BI
Understanding Explicit vs Implicit measures in Power BI
Related Posts:
Efficiency of measures in power bi
RANKX() issues in DAX, PowerBI
https://community.powerbi.com/t5/Desktop/Implicit-versus-explicit-measures/td-p/1196134

In Power Bi how to create a measure giving Number of Rows in a Table Visual

I know similarly named topics exist but I spent hours looking for the answer to something which i feel must be easy to do.
I have a table Visual in Power Bi and need to get a row count which would adjust as users set filters and use slicers.
The columns in the table don't have one level of hierarchy (otherwise a measure with DISTINCTCOUNT would do the trick), see an image of my table - I need to count rows in this table (21).
I couldn't find any way to directly refer to the Table Visual in DAX so simple COUNTROWS() wasn't useful. I tried to create a measure using various DAX expressions i found, e.g. recreate the table in DAX using CALCULATETABLE and have it use active filters, i failed there...
I also created an index variable on the physical/dataset table and tried to add it to the visual table and summarize it in some way (the column "Counter" in the table) - it didn't work, didn't give me the number of rows in the visual table but gave the number of rows in the physical/database table.
Please could you help me how to do this...
You won't really be able to access the table visual in the way you're thinking, but as long as you know how it comes together, that should be just as good.
CountSummaryRows =
CALCULATE(
COUNTROWS(SUMMARIZE(Table1, Table1[A], Table1[B], Table1[C], Table1[D])),
ALL(Table1)
)
This measure will aggregate to the level of your A,B,C,D columns, then count the total. ALL(Table1) just ensures you get the grand total, so every row should show as 21, but at least you'll have a handle on that summary table count.

Power BI - How to have a calculated column and place it in a merged cell?

I am new to Power BI and with the limited time given, I am stuck at how to come up with:
Below Table B-Row1 ("1/20" and "M"-Monday cell) - how to
specifically place the date measures in their specific cell and put
it in one column?
How can I merge the cells under the Total column?
How to add all the numbers from the Type1 and Type2 columns and place it in the merged cell in #2?
Any clues/direction/links on how to achieve the Target Table B below will be much appreciated.
PS. Below Table A. Current is just using Matrix Visualization in Power BI.
You can't exactly do what you are after. PowerBI allows you to rapidly put amazing visuals together however that comes at the price of lack of (easy) flexibility. You could build your own custom visual or look in App Source for a visual that does this, or build the Visual in some other tool (via custom code).
However, I'd recommend sticking with the PowerBI matrix, which will give you a cascading drill down and work out how best to align your data to it and other out of the box visuals. Once you start to delve in to convoluted work-arounds to give users data in exactly the format they request you start to burn a lot of time. Look for alternatives to tell the data's story and work with your end-user to buy in to it.
Just wanna share that I have resolved my problem not using one type of visualization, but through using 3 different visualizations in Power BI. I used:
1 Table visual for Date column
1 Table visual for Total column
1 Matrix visual for the Code+Type mapping and counts
I also used DAX function to get the Date format and another DAX function used for both Total and Code+Type counts(to filter data according to the specified date).
Thanks for the response, #Murray and #RADO.

What's the difference between DAX and Power Query (or M)?

I have been working on Power BI for a while now and I often get confused when I browse through help topics of it. They often refer to the functions and formulas being used as DAX functions or Power Query, but I am unable to tell the difference between these two. Please guide me.
M and DAX are two completely different languages.
M is used in Power Query (a.k.a. Get & Transform in Excel 2016) and the query tool for Power BI Desktop. Its functions and syntax are very different from Excel worksheet functions. M is a mashup query language used to query a multitude of data sources. It contains commands to transform data and can return the results of the query and transformations to either an Excel table or the Excel or Power BI data model.
More information about M can be found here and using your favourite search engine.
DAX stands for Data Analysis eXpressions. DAX is the formula language used in Power Pivot and Power BI Desktop. DAX uses functions to work on data that is stored in tables. Some DAX functions are identical to Excel worksheet functions, but DAX has many more functions to summarize, slice and dice complex data scenarios.
There are many tutorials and learning resources for DAX if you know how to use a search engine. Or start here.
In essence: First you use Power Query (M) to query data sources, clean and load data. Then you use DAX to analyze the data in Power Pivot. Finally, you build pivot tables (Excel) or data visualisations with Power BI.
M is the first step of the process, getting data into the model.
(In PowerBI,) when you right-click on a dataset and select Edit Query, you're working in M (also called Power Query). There's a tip about this in the title bar of the edit window that says Power Query Editor. (but you have to know that M and PowerQuery are essentially the same thing). Also (obviously?) when you click the get data button, this generates M code for you.
DAX is used in the report pane of PowerBI desktop, and predominantly used to aggregate (slice and dice) the data, add measures etc.
There is a lot of cross over between the two languages (eg you can add columns and merge tables in both) - Some discussion on when to choose which is here and here
Think of Power Query / M as the ETL language that will be used to format and store your physical tables in Power BI and/or Excel. Then think of DAX as the language you will use after data is queried from the source, which you will then use to calculate totals, perform analysis, and do other functions.
M (Power Query): Query-Time Transformations to shape the data while you are extracting it
DAX: In-Memory Transformations to analyze data after you've extracted it
One other thing worth mentioning re performance optimisation is that you should "prune" your datatset (remove rows / remove columns) as far "upstream" - of the data processing sequence - as possible; this means such operations are better done in Power Query than DAX; some further advice from MS here: https://learn.microsoft.com/en-us/power-bi/power-bi-reports-performance