I have a table like shown below:
ID
Date
Asset
Location
145
7/29/22
A
Market
145
7/30/22
A
Warehouse
145
7/29/22
B
Market
145
7/29/22
C
Truck
150
7/30/22
B
Market
145
7/29/22
D
Market
145
7/30/22
A
Market
What I am trying to accomplish is to get a distinct count of IDs for each date with a location filter as well. So I would want a count of ID based on the slicer selected Date of 7/29/22 AND 7/30/22 for the Market Location. The desired result is 2 for the selected dates from the date slicer which directly corresponds to the date column in the table.
I was trying to use this DAX formula and wasn't getting anywhere....
IDsMarket =
CALCULATE (
DISTINCTCOUNT ( 'Products'[ID] ),
ALL ( 'Products' )
)
I have a measure dropped onto a card. I should have specified that. My apologies. I need 1 measure to show me the combined count for the two days selected.
I tried this with countrows as well but of course the result wasn't distinct... Any help would be greatly appreciated!!
The formula you're looking for is
IDsMarket =
CALCULATE(
DISTINCTCOUNT('Products'[ID]),
'Products'[Location] = "Market"
)
The resulting Table will look like this
But if you put the measure on a Card visual, you'll get
So in DAX the same measure can yield 1000 different values - depending on the filter context.
I created a conditional column in Power Query and combined the ID with the "day" number from the date column which allowed me to then do a distinct count on that combined custom column which produced to correct answer. Sorry for all the confusion. One of those days.
I have calculated ranked using this formula which worked perfectly well :
RANK = RANKX(ALL(td_store[LIB_MAG]), CALCULATE(SUM(tf_market_share_by_store_nomcenclature[marche]),ALLEXCEPT(td_store,td_store[LIB_MAG])))
I have a slicer on the LIB_MAG which filter correctly my table :
However I don't want to see only the selected mag but the five previous and the last following mag, basing on the rank (in this exemple, the rank 121 to 131) like this :
Note that the rank is filtered on the LIB_RAY selected on an other slicer, so I did not succeed to pass by temporary tables ...
I tried this but it doesn't work because the RANK is a measure, not a column (it's not possible to use it in ALLEXCEPT) :
I tried this too but I don't succeed to extract the rank of the selected mag (because it's a measure again)
Have you got ideas to do this ?
I would need your support if possible..
Currently within my dataset there is a table "SUM" like below, where columns "Jan" and "Feb" contains both decimal and whole numbers data types.
Is it possible to convert some of the whole number to currency and some other to decimal with 2 decimal places ?
SUM TABLE
title
Jan
Feb
New users
80
90
users
200
150
BV
74562.62
82617.93
Charge
0.063629
0.061740
______________________________________
desired output
title
Jan
Feb
New users
80
90
users
200
150
BV
$745,626
$826,179
Charge
0.06
0.06
______________________________________
I think that in Power BI a column has only one data type.
Is there any way to achieve the desired output?
Thanks in advance
It would be best to structure your data, into a format that it can be used for example, change data types and creating measures.
In this example, using the query editor, you need to first Unpivot your Jan/Feb columns from columns to rows
With unpivot it becomes this:
You then need to Pivot your data on the Title, select the column 'Title' Pivot on the Values column created in the previous step
This now allows you to correct your formatting, create measures, and also map by month better, without the need for complicated DAX formatting when creating measures
To display several data type within a column, you need add new measure for each month you prepare to display and accept the answer if helping :)
Here is the dax formula for Jan, you may need calcuate for Feb if necessary:
Measure = IF(SELECTEDVALUE(Sheet1[title])="BV",FORMAT(SUM(Sheet1[Jan]),"Currency"),
IF(SELECTEDVALUE(Sheet1[title])="Charge",FIXED(SUM(Sheet1[Jan]),2),
FORMAT(SUM(Sheet1[Jan]),"General Number")))
By display the measure on the table, you will have the result:
To display different data types in a table, you can create a measure with the following DAX for the Feb column, you can do the same for other columns too.
Measure =
VAR VAL = SUMMARIZE('Table','Table'[Feb])
RETURN SWITCH( SELECTEDVALUE('Table'[Title]),
"Users", FORMAT(VAL, "0"),
"BV", FORMAT(VAL, "$0"),
"Charge", FORMAT(VAL, "0.00"),
"New Users", FORMAT(VAL , "0")
)
I'm "bugging" to transform my datas to something usable.
For the moment, a datasource provides me a table where a column contains dates, following by 24 columns representing each hours. In this 24 columns, for each date (each row) I've a total of phone calls.
I want to show the hourly repartition. So, my original datasource is not really usable ans need to transform it with something where there is a column "hour" (a simple index from 0 to 23 or 1 to 24) and a column with the total call for each column from the original column. But I'm a lot confused to do it because I don't have a way to create a relationship. Like this :
Someone have any idea to help me? Thanks in advance
I would unpivot the data source and then create two dimensions (Calendar) and (Time).
I have the following table:
I'm trying to create a new column using Dax language:
Column = DISTINCT('Edição'[País])
But I gott this error message:
A table of multiple values was supplied where a single value was expected.
The expected result is:
You have a source table with 21 rows. You want to add a column. In the end you'll still have 21 rows.
The "expected" table has 18 rows. So with only adding a column you will never get there, it's just impossible.
To get the expected output though, you can do this easily: just create a table with just Pais as values and PowerBI will automatically group. See here a (more minimal) example:
PS. If you wanted to add a column -say- with the number of years the country appears in the source data, you should:
choose the matrix visualization
add "Pais" (country) for rows
add e.g. "Ano" (year) for values, and summarize by "Count (Distinct)"