Converting text million value into number - power bi - powerbi

I did a few steps in Power BI. I have annual revenue column with high values as 600000000 and more..so I converted this column with number values into new column with million values:
I created new column annual revenue in millions using formula: AnnualRevenue(Millions) = format('Reporting HubSpotCompanyCurrentValueView'[annualrevenue], "#,0,,") so I got values like: 1, 10, 716 etc. but all these values are text values not number so my question here how is it possible to convert into numeric values? I need to numeric value as I want to create range based on annual revenue and count values in specific range. When I'm trying to convert new column with million values I got error that it's not possible. Anyone can help me?
annual revenue
annual_revenue(millions)
100000000
100
2879430000
2879,43

Note that you are using different terms for the same thing:
"annual revenue" vs. "annualrevenue"
"annual_revenue(millions)" vs. "AnnualRevenue(Millions)"
In Power BI this would cause problems.
To convert your annual revenue to a number of multiples of millions you could use either expression:
Annual Revenue (Millions) as Number = 'Table'[annual revenue] / 1e6
Annual Revenue (Millions) as Number = VALUE('Table'[annual_revenue(millions)])

Related

Power BI How to rank based on date closest to current date

I have a measure that calculates shortage dates of a column of items. How do I create a column/measure that outputs a 1-5 ranking based off how closely the shortage date of those items is with the current date. So a 10 would be the closest shortage dates. 5 = within one month, 4 = within two months, ... etc.

Creating a DAX formula that will count columns with Filters/Restrictions removed

I have the formula to count monthly rows in Excel if the margin amount is negative. If the latest month has a positive margin then the formula returns a "False" if the latest month has a negative margin, then it counts how many columns (months) have been negative in the past.
=IF($AP5<0,(COUNTIF(D5:AP5,"<0")))
What I'm trying to write is an equivalent DAX formula that will do the same thing.
My DAX Formula is:
Months Negative= CALCULATE(
DISTINCTCOUNT('Listing'[Report Date].[Month]), FILTER('Listing', 'Listing'[Margin] <0))
Example of the data:
enter image description here
When I have the report filtered by November, each customer only reflects that it had only been negative for 1 month (November). Instead of showing that a customer has been negative for like 3 or 10 months as of November. The formula doesn't count any of the months prior that are negative.
Does anyone know how to change the dax formula so that it still would reflect the total count each negative column regardless of if the data is filtered by November?

DAX: How to count how many months have sales in a period

In my fact table (fTable) the columns I have are dates, region and sales.
dates
region
sales
-----
------
-----
I am visualizing the data in a pivot table with regions as rows and months as columns (I have a date table (dDate) with a months column in my model)
I am looking for a way to dynamically change the denominator in an averaging measure if a certain region doesn't have sales in a given month. Right now my denominator is hard-coded as 6, because I am averaging 6 variables in my nominator, but any one of them could be 0 if I don't have any sales in a certain month, in which case my denominator needs to change to 5, 4 or less depending on how many months I don't have sales in. So I am looking to count how many of the past 6 months have sales and sum that as the denominator.
I have managed to count months with sales this way:
Denominator:=
var newTable = Summarize(fTable,fTable[date (month)], fTable[region],"Sales",[Sum of Sales])
var MonthsWithSales = Countrows(newTable)
RETURN
MonthsWithSales
I've tried to RETURN
Calculate(SUMX(newTable,MonthsWithSales), Dateadd(dDate[Date],-6,MONTH)
but it yields a wrong result.
Any suggestions?
Thanks
Based on my sample, we can use function VALUES & COUNTROWS inside CALCULATE to get what we need:
Measure = CALCULATE( COUNTROWS(VALUES('Table (2)'[Month])), ALL('Table (2)'[Month]) )

How to show the total values of rows in a Matrix with number value having my columns values as percentage

I've started to manage PowerBi from a couple of weeks so i'm a little bit confused about some things.
My problem is that i need a Matrix in my dashboard with percent values but i want the total in number value because the total of a percent of row shows me always 100% and i dont know about the number i'm working
This is my Matrix with percentage values
This is how i want the total of row returns me but with the columns values ins percentage
I've tried to make a measure counting the values
COUNT(OPSRespuestas[answer])
After that turn off the total of rows and add this measure to the values in my matrix but this is what i get
This is my table after trying add a measure with the total
It returns me the total for each of the columns and not the total of all my rows.
These are the tables i'm working with
This my top header values
This is my left header values
The answer column is what i need to count
This is my relationship between this 3 tables although i have many more intermediate table aside from this 3 as you're going to see in the next picture:
My relationship tables
So finally what i need is that this matrix shows me the total of answer in percentage for each of departments and group of questions and then show me total by department but with number value
The problem you are experiencing has to do with context. Each row is seen as it own total population hence the 100% total. Each column in this row is evaluated against the total of that row to provide a percentage value.
In addition to adding a custom measure to replace the total, you could also consider computing a percentage against the grand total of all dimensions. This means that each cell gets evaluated against the the total of all rows and columns. In this ways the cell value would change compared to your first table but the row total does not evaluate to 100% anymore.
SUM ( [Value] ) / CALCULATE ( SUM ( [Value] ) ; ALL ( 'Your Table' ) )

Power BI Calculated measure to count three specific values from a column

I have a table with 500 rows and one of the columns contains a few different values. I want to return a measure that counts the total number of three of the values.
So for example, in the pic below, I want to calculate the number of times Ages 11, 12 and 13 appears in the table - which is 7 times.
What is the DAX language for this?
Thank you
https://i.stack.imgur.com/50ci5.png
The 'IN' function will do this pretty cleanly. It will let you build a filter that limits your table to the rows whose values match the ones in a list that you supply. Then just count them up.
CountSpecificAges = CALCULATE(
COUNT (Table1[Age])
, Table1[Age] IN {11, 12, 13}
)