Get Daily sum in PowerBI - powerbi

I have a table with date and sales but when I applied summation to get daily sum it gives wrong results. I used:
Daily Sales = SUM(sales[Sales])
My original table:
Date
Sales
1/1/2018
454670
1/1/2018
458791
1/2/2018
454670
1/2/2018
458791
After using the formula, I get summation as below (which is wrong):
Date
Daily Sales
1/1/2018
99597528
1/2/2018
111423077
Please help!

Related

Calculating total daily sales orders in PowerBI using DAX

I am trying to get the total number of sales orders received daily. This will be sum of sales orders received + sum of sales shipments. Note that sales shipment has unique sales order number as well. There could be multiple sales shipments for 1 sales order, thus creating an error.
I am currently using:
Sales orders received = DISTINCTCOUNT (salesOrders[number]) + DISTINCTCOUNT(salesShipments[orderNumber]))
But this gives wrong number as sales order number can be in sales order table and sales shipment table both.
All I want is the distinct count of sales order numbers in Sales order table and Sales shipment table.
Any help is highly appreciated.
thank you

Month field is not getting drill down in power bi

I am calculating total revenue over the years.
There are two tables calendar and sales. I have calculated total revenue using DAX now I want to display total revenue in each year.
The month field is not getting filtered for the Revenue column, I have attached a snip for reference.
Total revenue(DAX)= total revenue = SUMX(AW_Sales,AW_Sales[OrderQuantity] * RELATED(AW_Products_Lookup[ProductPrice]))

Power BI cumulative count with DAX

Here is a table of two rows:
ItemID
Date1
Date2
Category
1
2019-03-18
2020-07-31
A
1
2020-10-18
2020-07-31
A
Cumulatively count the number of unique items by category where Date1 >= Date2
I created a measure (thanks #jprzd) for a column chart:
Measure = CALCULATE(DISTINCTCOUNT(Table[ItemID]),FILTER(ALLSELECTED(Table),Table[Date1]>=Table[Date2]))
It does not result in the correct cumulative count. I think the above DAX expression is likely in the right direction, but I couldn't figure out where it went wrong.
I'd greatly appreciate your help.

Calculate total variance in power bi with dax

I have 3 measures:
1) total_trx = SUM(mytable[trx])
2) trx_prev_month = CALCULATE([total_trx], DATEADD(calendar[date], -1,MONTH))
3) monthly_var = DIVIDE([total_trx],[trx_prev_month])-1
If I add a waterfall viz, x-axis with month, it gives me the % of monthly variation and a TOTAL bar at the end that sums all the variations.
I need to reproduce that total number in order to show a KPI as in "so far, we've increased ...%", changing when using a date slicer.
Seems like sum(monthly_var) is not allowed.
Any ideas?
Thank you very much.
Edit1: sample with date filter = Last 4 months
Jul 100 0%
Aug 110 10%
Sep 90 -20%
Oct 80 -10%
Total: -20% <- need a dax to calculate this number and show just -20%
Then if I change the filter to, for example LAST 6 MONTHS, I need to calculate it up to May
In order to get the desired result we will use an intermediate table in our query that will summarize the results by months:
use this code and replace calendar[Year Month] with your Year month column :
SUMX(
SUMMARIZECOLUMNS(calendar[Year Month],"Monthly_int_var",[monthly_var]),
[Monthly_int_var]
)

How to calculate Annual Variance on Monthly basis?

Am new to Power BI and appreciate help on DAX for this requirement:
I have a FY slicer (July-June) in my Power BI reports and wants to show monthly trending across different FY years. Target data is structured like this in a table:
Dates | Target
30-06-2018 | 34000
30-07-2018 | 34000
30-08-2018 | 34000
********** | *****
30-06-2019 | 30000
30-07-2019 | 30000
********** | ******
I need to calculate annual variance with below formula to get monthly baseline for next year(2019), then calculate cumulative reduction variance across July-June:
('Target of 30-06-2018') - ('Target of 30-06-2019')/ 12
Dates are linked to another DATE table, which has Financial year and Financial month columns.
Thanks so much in advance for the help!!
Anita
You need to use the DAX PARALLELPERIOD
PARALLELPERIOD(<dates>,<number_of_intervals>,<interval>)
The documentation gives a perfect example:
= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]), PARALLELPERIOD(DateTime[DateKey],-1,year))
So your calculation will something like:
= (
CALCULATE(SUM(TargetTable[Target])) -
CALCULATE(SUM(TargetTable[Target]), PARALLELPERIOD(Dates[Date],-1,year))
) / 12
If you want monthly variance, then you need to ensure that Dates[Date] is filtered at a grain to return a table of dates for the entire target month.
You can find a great blog on it here
For next year, I got June Baseline value with SAMPLEPERIODLASTYEAR.
1: Last year value = CALCULATE(SELECTEDVALUE (TargetTable[Target]),
SAMPLEPERIODLASTYEAR (Dates[Date]))
2: Base Target = IF (MONTH(SELECTEDVALUE(TargetTable[Dates])=6, DIVIDE ([Last year value]-SELECTEDVALUE (TargetTable[Target]), 12))
Still need to figure out Cumulative monthly variance across next financial year?