PowerBi Distinctcount not working properly with 3 measures - powerbi

I am having an issue using the Distinctcount function in DAX. I have a table with a total of 1,154,493 rows. I have a measure created to count the number of distinct values in column 1. I have another measure created to count the number of distinct values in column 1 with filters. I have a 3rd and final measure created to count the number of distinct values of column 1 with different filters. The issue I am running into is the count of measure 2 + measure 3 should equal measure 1 however added together they are GREATER than the value of measure 1 which is just a grand total. How is this possible? Unfortunately I can't share the table but below is the code I am using for the two measures:
Measure1=distinctcount('Table1'[Column1])
Measure2=calculate(distinctcount('Table1'[Column1]),'Table1'[CTest] = 1,'Table1'[CTest2] = "07")
Measure3=calculate(distinctcount('Table1'[Column1]),'Table1'[CTest] = 2,'Table1'[CTest2] = "07")
I am at a loss. Thank you in advance!!

For troubleshooting you should identify values of Column1 with Measure2 and Measure3 > 0, those are being added twice.

Related

DAX - DISTINCTCOUNT based on measure

I have the following dataset:
and the following measures:
Count of Filters = if(ISFILTERED(Table1[Product]), COUNTROWS(FILTERS (Table1[Product])), 0)
Count = if(ISFILTERED(Table1[Product]), COUNT(Table1[Unique_ID]),0)
What I would like to to is, when I filter the table at Product, that a measure disctinct counts the unique_ID that have a count equivalent to the count of filters.
The following should be able to explain better:
When filtering to product 1, A list of all appear, because they all have product 1:
But when also selecting Product 2, A and B have a total count of 2 because they have entries for both product 1 and 2.
Now, what I ultimately want, is a measure that can do a distinctcount on only the Unique_ID that have the Count equal the count of filters. In the above scenario, I would want the total to give me 2 (as only UNIQUE_ID A and B have both products 1 and 2).
I have put together the following:
Total = CALCULATE(DISTINCTCOUNT(Table1[Unique_ID]),FILTER(Table1, Table1[Count]=Table1[Count of Filters]))
but this doesn't seem to work. I understand why it's not working, but I can't seem to figure out how to put together a measure to calculate this for me.
Many thanks in advance!

How to calculate the percentage of daily total from two columns of different sizes and tables in Power BI?

I am trying to group the values from the table below according to day
in order to calculate the daily percentage relative to the total, which is located in the table below
FYI,
Both tables are linked by the DUID variable (Many-to-one relationship)
The final result should be the following:
I did it in four steps:
Generated a Date Table;
Created three measures in the new Date Table:
Measure 1: PASA_DAY = CALCULATE(SUM(MTPASA[PASAAVAILABILITY]))
Measure 2: TtlGenCpcty = CALCULATE(SUM('ExistingGeneration&NewDevs'[TotalNmPltCpcty]),ALL('ExistingGeneration&NewDevs'[TotalNmPltCpcty]))
Measure 3: Measure = DIVIDE('Date Table'[PASA_DAY],'Date Table'[TtlGenCpcty])
Is there a way to do this in less steps?
Thank you in advance. I appreciate it.
Have a nice day :^)

How do I manipulate measure values based on 2 other dimension tables

Power BI newbie here and I'm trying to figure how to craft my DAX to manipulate my measure values based on certain criteria in the other two tables.
Currently I have 2 separate tables which are joined by a One to Many relationship and a separate Measures table. (Total Sales Price is computed as sum of Sales Price)
My aim is to create a new measure where Total Sales Price is multiplied by 1.5x when DIM_Product_Type[Product Category] = "High".
New Measure =
CALCULATE (
SUM ( FACT_PriceDetails[Sales Price] ),
FILTER ( DIM_Product_Type, DIM_Product_Type[Product Category] = "High" )
) * 1.5
However this returns no values in my visual and I'm trying to discern if its a matter of the table joins or the DAX expressions.
Thank you for your time!
Your measure seems good.
It will select only those products with a Product Category of "High" and multiply them by 1.5 to give you result. i.e. Give me the sum of all "High" Product category Price details multiplied by 1.5.
What you need to check is:
Product Serial Numbers match across the two tables
Your Product Category does indeed contain the category "High"
You have entries in FACT_PriceDetails that link to a DIM_Product_Type that has a category of "High"
Check you have not set any filters that could be hijacking your results (e.g. excluding the "High" product category product type or the realated fact/s)
Option-1
You can do some Transformation in Power Query Editor to create a new column new sales price with applying conditions as stated below-
First, Merge you Dim and Fact table and bring the Product Category value to your Fact table as below-
You have Product Category value in each row after expanding the Table after merge. Now create a custom column as shown below-
Finally, you can go to your report and create your Total Sales measure using the new column new sales price
Option-2
You can also archive the same using DAX as stated below-
First, create a Custom Column as below-
sales amount new =
if(
RELATED(dim_product_type[product category]) = "High",
fact_pricedetails[sales price] * 1.5,
fact_pricedetails[sales price]
)
Now create your Total Sales Amount measure as below-
total_sales_amount = SUM(fact_pricedetails[sales amount new])
For both above case, you will get the same output.

how to aggregate columns from multiple tables in power bi

I have two tables here and I want to sum up measure 3 and measure 4.
both the measures are calculated once. I want to show sum against every country I have in the tables eg: Germany(0.31+0.18= 0.49)
model data
new result
Have your tried :
NewMeasure := SumX(Filter(Country, AND(Measure4 <> Blank(), Measure3 <> BLANK()) ), MEASURE 3 + MEASURE 4)
and then on PowerBi on the data view you select your measure and change the format to be with 2 decimal values.

Cumulative Values row wise and with date filter minimum and maximum in DAX(Power BI)

I need help in calculating the cumulative frequencies row wise with minimum date and maximum date selection by users using sliders. Here is the table that I want to generate could you please guide me? I've tried various function and methods but nothing is giving me right answer. Thanks a lot in advance.
Below is the table that I've and I want to generate:
Original Table
Desired Table
To create a running total, create a new measure in your table like this (where Table is the name of your table):
Running Total = CALCULATE(
SUM('Table'[Values]);
FILTER(ALLSELECTED('Table'); 'Table'[Date] <= SELECTEDVALUE('Table'[Date]))
)