Forum Widgets
Recent Discussions
Power BI DAX Challenge – ALLSELECTED vs Correct Grand Total
I have a fact table with sales document and other columns. For reporting purposes, I need to display the total Sales Order Weight at the Sales Document level, so I use ALLSELECTED() to ignore the other row context while still respecting report slicers. Current requirement Suppose the raw data is: Sales Document Item Bill of Lading Weight SO1 10 BOL1 600 SO1 20 BOL2 594 I need my report to show: Sales Document Bill of Lading Sales Order Weight SO1 BOL1 1194 SO1 BOL2 1194 The repeated value is intentional. Slicer requirement If the user filters Classification, Material, Delivery, Plant, etc., the measure must respect those slicers. Example: If only Item 10 remains after a slicer, the measure should return 600, not 1194. This is why I'm using ALLSELECTED() instead of REMOVEFILTERS(). The problem The row values are correct, but the Grand Total is incorrect because the repeated Sales Document weight gets summed multiple times. The expected total is: 1194 but Power BI returns: 1194 + 1194 = 2388 (or similar duplication depending on the number of Bill of Lading rows). Current measure (simplified) CALCULATE( SUM('Sales&Delivery'[Sales Order Weight of the Item in Grams]), 'Sales&Delivery'[Delivery] <> BLANK(),ALLSELECTED('Sales&Delivery'[BillOfLadingDrvd]), ALLSELECTED('Sales&Delivery'[Delivery]), ALLSELECTED('Sales&Delivery'[Default Plant]), ALLSELECTED('Sales&Delivery'[PlantDelivery]), ALLSELECTED('Sales&Delivery'[ActualGoodsMovementDate]), ALLSELECTED('Sales&Delivery'[Classification]) ) Things I've already tried SUMX(VALUES(SalesDocument), ...) SUMMARIZE() ALLEXCEPT() KEEPFILTERS() TREATAS() Calculated column approach Visual Calculations None of them satisfy all three requirements simultaneously. Question How can I write a DAX measure that: Repeats the Sales Order Weight for every belonging to the same Sales Document. Respects all report slicers (Material, Classification, Delivery, Plant, etc.). Produces a Grand Total that counts each Sales Document only once instead of summing the repeated values. Is there a DAX pattern for this?aayushianand978 hours agoNew Member47Views0likes3CommentsHelp with DAX
Dear Pros, Need help here I have a monthly recurring charge (MRC) from multiple customers that continues every month until the end of their contracts. I want to calculate the MRC amount for each month. For example, Customer A starts billing in January and pays $100 every month until the contract ends, while Customer B starts billing in March and pays $50 every month until the end of the contract. So I want see how much money we have received every month and from which customers. Something like this Jan - 100 Feb - 100 Mar - 100+50 Apr - 100+50 .... so on Note : I don't have the end of the MRC month date but I have the start of the MRC billing and number of billable months in each year please help with daxLio12310 hours agoAdvocate I45Views0likes5CommentsWeight in survey data
I have a large amount of data from two surveys and i'm struggling with calculating certain percentages. I've tried to simplify it a lot here, but it does require a long setup. In the data every respondent has been given an individual weight, so that for instant respondents in an age group with few respondents might count for a bit more than those in other age groups. Therefor in a given answer, it is not number of respondents but the sum of their weight that's the relevant. The table for respondents look something like this, but with many more columns.: 'Respondents' ID Age Weight 1 55 0,7 2 17 1,2 3 21 1,1 For quite a few questions the respondents could answer by choosing several options for instance "Which of the following options are you familiar with: A, B, C...". This give a tabel like: ID Uses A Uses B Uses C 1 0 1 1 2 0 0 0 3 1 0 1 The only way I can count those replies is by copying the table, remove unnecessary columns and unpivot columns A, B, C, so I get the following table which is related to the respondent tabel by ID: 'Q1_Options' tabel ID Uses Weight 1 B 0,9 1 C 0,9 3 A 1,3 3 C 1,3 However, not all respondents have been asked all questions. So when calculating how many percentage answered yes to an option, the sum of weight of those answers should be held op against the collected weight of only those respondents, that have been asked the question. In the example here the weight of for instance option A is 1,3. The collective weight of the respondents who have been askes the question (ID 1 and 3) is 1,8 1,3 / 1,8 = 72% But how do I write a dax query that can calculate the collective sum of only those who replied and where their weight is only counted once, but also is resistant to filters and rows so if can be used in the calculation of percentage? My best guess so far is this, which doesn't work: CALCULATE( SUM('Respondents'[weight], TREATAS( VALUES('Q1_Options'[ID]), Respondents[ID] ) ,ALL('Options-table') ) It does return the right total, but when I put it in a matix it just calculates the weight of the answers, and therefor the percentage just returns 100% on all. I've also tried with REMOVEFILTERS with no difference.SolvedKathrinens1 day agoFrequent Visitor30Views0likes2CommentsComparaison de courbes en S par jalon et par quarter — Quelle architecture DAX ?
Bonjour à tous, Je travaille sur un rapport Power BI de suivi de production et j'aimerais avoir vos conseils sur l'architecture à adopter. Contexte Je suis en train de construire des courbes en S cumulatives qui mesurent, jour après jour, le pourcentage de SKU-SITE ayant atteint un jalon de production donné. Disons que les jalons suivis sont : Jalon1, Jalon2, Jalon3. Les données sont organisées par quarters : 24Q1, 25Q1, 26Q1, etc. Mon modèle de données est le suivant : Dim_SKU (one) → Fact_SKU-SITE (many) par le code SKU (Dim_SKU stock les infos de mes skus, la fact sku-site m'apporte une combinaison entre un sku et site de production (pk) car un sku peut se retrouver dans plusieurs site de production) Une table disconnected Axe X Courbes S utilisée comme axe X, reliée à Fact_SKU-SITE via des relations inactives activées par USERELATIONSHIP. La timeline se calcule comme cela : Date Event (un évènement important pour le début de la prod) -> JalonX (en jours), chaque timeline a donc une relation inactive avec ma table X courbes S [value] Ce que je veux obtenir Afficher sur un même graphique en courbes, plusieurs séries superposées correspondant à des combinaisons librement choisies, par exemple : Jalon1 26Q1, Jalon1 25Q1, Jalon2 26Q1, etc. L'idéal serait de pouvoir sélectionner les combinaisons à afficher via des slicers. Ce que j'ai déjà Une mesure fonctionnelle par combinaison jalon × quarter, construite ainsi : % Courbe S Event > Jalon1 26Q1 = VAR Jour = SELECTEDVALUE('Axe X Courbes S'[Value]) VAR Numerateur = CALCULATE( DISTINCTCOUNT('Fact_SKU-SITE'[PK_SKU_x_Site]), USERELATIONSHIP('Axe X Courbes S'[Value], 'Fact_SKU-SITE'[Event > Jalon1 (jrs)]), FILTER(ALL('Axe X Courbes S'), 'Axe X Courbes S'[Value] <= Jour), 'Fact_SKU-SITE'[Jalon1 Statut A/B] = "A", NOT(ISBLANK('Fact_SKU-SITE'[Event > Jalon1 (jrs)])), KEEPFILTERS(FILTER(ALL('Dim_SKU'), 'Dim_SKU'[SKU Quarter (pour filtre)] = "26Q1")) ) VAR Denominateur = CALCULATE( [NB SKU-SITE], KEEPFILTERS(FILTER(ALL('Dim_SKU'), 'Dim_SKU'[SKU Quarter (pour filtre)] = "26Q1")) ) RETURN DIVIDE(Numerateur, Denominateur) Le problème Pour afficher N courbes superposées sur un même graphique, Power BI nécessite N mesures distinctes dans le puits Valeurs. Avec 3 jalons × 4 quarters, cela représente déjà 12 mesures. Le nombre va croître avec les quarters. L'IA m'a envisagé une architecture avec : 1 mesure métier par jalon contenant toute la logique 1 wrapper one-liner par combinaison appelant la mesure métier avec le quarter forcé Mais je me demande s'il existe une approche plus élégante, notamment via Field Parameters, Calculation Groups, ou toute autre technique qui permettrait de réduire le nombre de mesures tout en conservant la possibilité d'afficher plusieurs courbes superposées de différent jalons et différent quarter sur un même graphique. Merci d'avance pour vos retours ! Désolé pour la longueur du post, mais j'ai préféré ajouter plus de contexte que pas assezWanou4 days agoNew Member64Views0likes4CommentsHelp with DAX and report level filters
I need to convert the below dax formula to ignore the report level filter of DimSeller[SalesId] but honor the visual level filter of DimSeller[Sales NSAA Region]. Reservations = var selection = SELECTEDVALUE(DateSelect[SelectId]) RETURN SWITCH(true(), selection = 1, CALCULATE(FactReservation[Res By Res Date]), selection = 2, CALCULATE(FactReservation[Res By Check In Date])) I've tried Reservations = var selection = SELECTEDVALUE(DateSelect[SelectId]) RETURN SWITCH(true(), selection = 1, CALCULATE(FactReservation[Res By Res Date], All(DimSeller[Salesid]), KEEPFILTERS(DimSeller[Sales NSAA Region]).... with no luck. I've also tried creating a second table for the Sales NSAA Region values and using it as the visual level filter but still have not been able to get it ignore the report level filter and keep the visual level filter. The only way I've gotten to work is creating a measure that hardcodes the DimSeller[Sales NSAA Region to the value. However, if I go this route I'll have to create 48 measures so hoping there is a way to get a single measure to work.Solvedjslade5 days agoHelper I79Views0likes3CommentsBug: Base64 Text Measures break down when having Calculation Groups
Hi all. I have a few concatenate measures to bypass the 32000-character limit in Power BI - They all work fine until I add a calculation group and calculation item - they all break down then. You don't even have to use it - the mere existence of a calculation item is enough to break them. I cannot find much info on the web about this very niche issue. Hopefully, someone has an answer/explanation. Cheers, Quangmmqqq199995 days agoRegular Visitor440Views0likes1CommentHow to compare static table to updated table, find rows that changed?
At the start of each month, I take a snapshot (TABLE1) of a live data table (TABLE2). TABLE2 has three relevant columns that defines a unique row (Title, Amount, Salesperson), and a fourth column that can change (Date): Title Amount Salesperson Date The snapshot also adds a "Snapshot date" column. it's relevant headers look like: Title Amount Salesperson Date Snapshot Date There's a table visual to display these snapshot items and a Year, Month slicer (Relationship: CalenderTable[Date] -> TABLE1[Snapshot Date]) to filter the snapshots to only a specific month. I now want to compare these snapshot items to the live data table and have the table visual only show rows where the Date column changed to a later date. After some googling, I created a Measure I can use to filter the table visual to values of "1", but the date comparison doesn't seem to be working right. It's returning some rows where the Date in TABLE2 was changed to earlier (we don't care about those) than the Date in TABLE1 and I can't figure out why. Rolled = If( COUNTROWS( CALCULATETABLE(TABLE2 , TABLE2[Name] = SELECTEDVALUE(TABLE1[Name]) && TABLE2[Amount] = SELECTEDVALUE(TABLE1[Amount]) && TABLE2[Salesperson] = SELECTEDVALUE(TABLE1[Salesperson]) && TABLE2[Date] > SELECTEDVALUE(CalendarTable[Date]) ) ) > 0, 1, 0 ) Example of wrongly listed TABLE1 row: TABLE2 is not connected by any relationships. I manually applied filters to show the same row to see if the measure worked properly. What am I doing wrong or is there a better way to do this?SolvedCayshin7 days agoFrequent Visitor53Views0likes3CommentsDAX - remove decimal places in measure
I have the following measure but not sure how to make it so it returns 0 decimal places in result. Count Employee No Blank = IF(ISBLANK(COUNT('Employee List'[Full Name])), "0", COUNT('Employee List'[Full Name])) Thank you!SolvedLauri8 days agoNew Member5.4KViews0likes3CommentsSUMX Not Working
I have created a sample dashboard based on the AdventureWorks sample database and I cannot figure out why I cannot get this to work. I can evaluate every VAR throughout except _Result which never works. I have attached a photo of _FilteredTable, which you can see is a very simple table with a total. (the code snippet is showing up incorrectly, so I've also included a screenshot of the fairly simple code) DEFINE VAR _TableWithBadNames = SUMMARIZECOLUMNS ( 'Production ProductCategory'[Name], 'Sales SalesOrderHeader'[OrderDate].[Year], "@Total", SUM('Sales SalesOrderDetail'[LineTotal]) ) VAR _Table = SELECTCOLUMNS( _TableWithBadNames, "@Category", [Name], "@Year", [Year], [@Total] ) VAR _FilteredTable = FILTER(_Table, [@Category]="Accessories" && [@Year]=2011) VAR _Result = SUMX(_FilteredTable, [@Total]) EVALUATE _ResultSolvedronnie_roberts8 days agoHelper I34Views0likes2CommentsMeasure for drilling down on a pie chart with categorical data, excluding blank cells
Hello all. Here is some dummy data for what I am trying to accomplish: Respondent Alumni Alumni Level Alumni Undergrad Program 1 Yes Undergraduate Elementary Education 2 No 3 Yes Graduate 4 Yes No 5 Yes Undergraduate Middle School Education 6 Yes Graduate 7 No Of course I have unpivoted by Respondent (which is not shown here). What I would like to do is have a pie chart showing "Alumni" and then be able to drill-down on the percentage that have answered "Yes" so I can see the percentage for "Alumni Level" and then even further drill down to the percentage for "Alumni Undergrad Program." Of course, I would need to disregard the respondents that answered "No" for the "Alumni" question. Thanks so much!afaherty8 days agoHelper V364Views1like11Comments