I have the following column with two different kind of data formats. I want to show it in a matrix visual and add thousand separators using dax. I know it's not ideal but due to different requirements it has to be like this.
Category
Amount
Euro
1000
Total Stock
20000
Euro
500
Total Stock
4432423
Euro
23132
Total Stock
23423
Euro
3232
Total Stock
433
Euro
42424
Total Stock
12312
Euro
4545
Total Stock
32233
I created a measure for changing the format like the following:
Measure_Amount =
Var varAmount = sum(table[Amount])
RETURN
SWITCH (
SELECTEDVALUE ( 'table'[Category] ),
"Total Stock", Format(varAmount, "#;-#;#"),
"Euro", Format(varAmount, "#€;-#€;#€"))
In short, it will change the format based on the Category column but it will be formated as text.
It will show like this in Power BI. I have added the Amount column as row just to show the difference.
I would like to add thousand separators in the measure but I don't know how? Can anybody help? The default way to click it in Power BI doesn't work since the measure is formatted as text now.
How about adding the thousands separator to the format strings?
Formatted_Amount =
VAR varAmount =
SUM ( 'table'[Amount] )
RETURN
SWITCH (
SELECTEDVALUE ( 'table'[Category] ),
"Total Stock", FORMAT ( varAmount, "#,###" ),
"Euro", FORMAT ( varAmount, "#,###€" )
)
Related
I have made an measure for showing total sales by each person. I can't figure how to make an measure for dividing total sales by each person BY total sales. For example, for the person "bmo" I want to calculate 303/3153 and so on.
I have tried using the same measure as I use on "Totalt antall salg" and use the Show value as, but that just shows the correct value, and does not calculate it, and I need to use the number for later.
You can ignore filter context by using ALL to get total sales:
VAR _TotalSales =
CALCULATE (
COUNTROWS ( 'KasseJournal' ),
FILTER ( ALL ( 'KasseJournal' ),
'KasseJournal'[Hendelse] = "Bekreftet kasseekspedisjon"
)
)
RETURN DIVIDE ( [Totalt antall salg], _TotalSales, 0 )
I'm newbie in PowerBI user.I create simple sale report and measurement. Like This :
My problem.In PowerBI show % calculate only Net sale and total rows but I need all % sale result like this :
Please suggest me how to solve this problem.This's my Code.
% to Sales = round(DIVIDE(
sum(DAILY_PNL_FF_TH_V2[VALUE]),
CALCULATE(sum(DAILY_PNL_FF_TH_V2[VALUE]),FILTER(ALLSELECTED(ERP_ACCOUNT[group_1]),ERP_ACCOUNT[group_1]="Net Sales")
))*100,2) &"%"
If you are trying to get the Percent of each group relative to Net Sales, then you can try something like below:
% to Sales =
VAR netSalesAmount =
CALCULATE (
SUM ( DAILY_PNL_FF_TH_V2[VALUE] ),
ERP_ACCOUNT[group_1] = "Net Sales"
)
RETURN
DIVIDE ( SUM ( DAILY_PNL_FF_TH_V2[VALUE] ), netSalesAmount )
Also, it is better to address formatting in the screen below so that the number is treated as a number rather than text. This is both for sorting and exporting the data. Also, it keeps the calculation simpler:
I am working in Power BI and I created a DAX measure that adds up two other DAX measures.
For one measure I need it to ignore the month slicer because I need the total for that category. Is it possible to do so?
Also, is it possible for it to ignore the slicer and still give me the total for unfiltered DAX measure + the date filter DAX measure?
DAX code:
Monthly Total Act =
CALCULATE (
SUM ( 'sheet1'[Amount] ),
FILTER ( 'sheet1', 'sheet1'[Type] = "ACT" ),
FILTER ( 'sheet1', 'sheet1'[Bill] = "Y" )`
)
Monthly Total of Acs =
CALCULATE (
SUM ( 'sheet1'[Amount] ),
FILTER ( 'sheet1', 'sheet1'[Type] = "ACR" ),
FILTER ( 'sheet1', 'sheet1'[Bill] = "Y" )`
)
Adding these two formulas together to get the total monthly.
The monthly total of ACS is where I encounter the problem. I need this to be unaffected by the slicer
The end goal is having the month total of ACS unaffected by the data slicer and add to the monthly total of Act that requires filter by the current month.
Yes, you can add this line as a third filter argument in the calculat function you want to ignore the month slicer:
ALL('tableName'[monthColumnUsedAsSlicer])
Then the monthe slicer will not affect calculations.
I am facing this issue in understanding how to add a measure Amount LTD which looks back to all the data for projects since its start.
I am able to give total amounts per project between the dates on the data slicer but unable to get Amount which looks back beyond the data filters applied and get the LTD sum value till the to date selected on the date slicer.
Can someone please help.
TIA.
See this Cumulative Total pattern.
Cumulative Quantity :=
CALCULATE (
SUM ( Transactions[Quantity] ),
FILTER (
ALL ( 'Date'[Date] ),
'Date'[Date] <= MAX ( 'Date'[Date] )
)
)
We have requirement to allow user to choose which currency he wants to see in the dashboard, like below example:
By default, it's GBP, if user changes to USD, we need to show the spend by USD. Under the hood we already have table InvoiceDetail which contains columns doing currency conversion beforehand:
SpendInGBP
SpendInUSD
SpendInEUR
I am not sure how I can map when user chooses different currency using ChicletSlicer to different Columns.
If you have a table containing all formats available to apply this can be achieved.
I've created these tables as example:
MyTable
CurrencyFormat
In the MyTable table I've created two measures called Format and Total Sales.
Format = LASTNONBLANK ( CurrencyFormat[Format], 1 )
Total Sales = Total Sales = FORMAT(SUM(MyTable[Sales]),[Format])
Note Total Sales measures uses the [Format] measure to get the selected format from the slicer.
Adding the ChicletSlicer and setting FormatName column from CurrencyFormat table in Category pane, you should get the expected result.
Also note the formats I've used can vary from what you need, so you have to add some changes to the format strings, do a quick read of the documentation about it.
Format Region
$#,##0;($#,##0) SpendInUSD
£#,##0;(£#,##0) SpendInGBP
€#,##0;(€#,##0) SpendInEUR
UPDATE: OP wants to get the sum of the right column based on the slicer.
Fortunately your table has a column for every currency, as you found with my proposal to map the slicer value to your measure, this is the final expression:
Spend =
IF (
LASTNONBLANK ( 'Currency'[Code], 1 ) = "GBP",
SUM ( Invoice[SpendGBP] ),
IF (
LASTNONBLANK ( 'Currency'[Code], 1 ) = "USD",
SUM ( Invoice[SpendUSD] ),
SUM ( Invoice[SpendEUR] )
)
)
Let me know if you need further help.